Skip to content

Commit eefd0d2

Browse files
committed
skeleton for fcs signal prediction
1 parent 3a93a96 commit eefd0d2

File tree

5 files changed

+149
-0
lines changed

5 files changed

+149
-0
lines changed

Diff for: .gitmodules

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
[submodule "app/precomputed-data-table-app/xplan-od-growth-analysis"]
22
path = app/precomputed-data-table-app/xplan-od-growth-analysis
33
url = https://gitlab.sd2e.org/rpg/xplan-od-growth-analysis.git
4+
5+
6+
[submodule "app/precomputed-data-table-app/fcs_signal_prediction"]
7+
path = app/precomputed-data-table-app/fcs_signal_prediction
8+
url = https://gitlab.sd2e.org/dbryce/fcs_signal_prediction
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python
2+
3+
# pylint: skip-file
4+
5+
from setuptools import setup, find_packages
6+
7+
install_requires = [
8+
9+
]
10+
11+
setup(
12+
name="fcs_signal_prediction",
13+
version="0.1",
14+
description="Python module to predict the output signal of a strain based upon its FCS data.",
15+
url="https://gitlab.sd2e.org/dbryce/fcs_signal_prediction",
16+
author="Daniel Bryce",
17+
author_email="[email protected]",
18+
license="MIT",
19+
packages=find_packages('src'),
20+
package_dir={'': 'src'},
21+
install_requires=install_requires,
22+
zip_safe=False,
23+
include_package_data=True
24+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
2+
from fcs_signal_prediction.predict import predict
3+
4+
def main():
5+
predict(None, None)
6+
7+
8+
if __name__ == '__main__':
9+
main()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from pandas import DataFrame
2+
3+
4+
def predict_signal(df: DataFrame, experiment_identifier: str) -> DataFrame:
5+
pass
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
"""
2+
run xplan_od_growth_analysis on plate reader data frames produced by Data Converge;
3+
4+
example command:
5+
python run_od_growth_analysis.py "YeastSTATES-CRISPR-Short-Duration-Time-Series-20191208"
6+
7+
:authors: Robert C. Moseley ([email protected])
8+
"""
9+
10+
import pandas as pd
11+
import argparse
12+
import os
13+
from xplan_od_growth_analysis import analysis_frame_api
14+
15+
16+
def grab_pr_dataframe(exp_ref, er_dir):
17+
18+
pr_file_name = '__'.join([exp_ref, 'platereader.csv'])
19+
platereader_df = pd.read_csv(os.path.join(er_dir, pr_file_name))
20+
21+
return platereader_df
22+
23+
24+
def grab_meta_dataframe(exp_ref, er_dir):
25+
26+
meta_file_name = '__'.join([exp_ref, 'fc_meta.csv'])
27+
meta_df = pd.read_csv(os.path.join(er_dir, meta_file_name))
28+
29+
return meta_df
30+
31+
32+
def growth_analysis(platereader_df, exp_ref, out_dir):
33+
34+
od_analysis_df = analysis_frame_api.augment_dataframe(df=platereader_df, experiment_identifier=exp_ref)
35+
36+
return od_analysis_df
37+
38+
39+
def rows_to_replicate_groups(data_df, m_type):
40+
41+
if m_type == 'od':
42+
# drop duplicates and induction samples
43+
# *** This will be replaced when replicate group column is added
44+
dup_cols = ['doubling_time', 'n0', 'inducer_type', 'well', 'experiment_id']
45+
data_drop_df = data_df.drop_duplicates(subset=dup_cols, keep='first')
46+
data_drop_df.dropna(subset=['inducer_type', 'inducer_concentration',
47+
'inducer_concentration_unit'], inplace=True)
48+
# drop sample-specific columns
49+
drop_cols = ['_id', 'sample_id', 'replicate', 'timepoint', 'timepoint_unit', 'container_id',
50+
'aliquot_id', 'fluor_gain_0.16', 'fluor_gain_0.16/od']
51+
data_drop_df.drop(drop_cols, axis=1, inplace=True)
52+
# ***
53+
return data_drop_df
54+
55+
elif m_type == 'fc':
56+
# *** This will be replaced when replicate group column is added
57+
# drop duplicates
58+
dup_cols = ['well_id', 'experiment_id']
59+
data_drop_df = data_df.drop_duplicates(subset=dup_cols, keep='first')
60+
# drop sample-specific columns
61+
drop_cols = ['_id', 'sample_id', 'replicate', 'timepoint', 'timepoint_unit', 'TX_plate_name']
62+
data_drop_df.drop(drop_cols, axis=1, inplace=True)
63+
# ***
64+
return data_drop_df
65+
66+
# happen outside of this module *****
67+
# def merge_growth_fc(growth_df, fc_meta_df):
68+
#
69+
# growth_fc_df = fc_meta_df.merge(growth_df, )
70+
71+
72+
def run_od_analysis(exp_ref, exp_ref_dir, conf_dict, out_dir):
73+
74+
pr_df = grab_pr_dataframe(exp_ref, exp_ref_dir)
75+
od_analysis_initial_df = growth_analysis(pr_df, exp_ref, out_dir)
76+
# od_analysis_initial_df.to_csv(os.path.join(out_dir, 'pdt_{}__od_growth_analysis.csv'.format(exp_ref)))
77+
78+
# make df rows = replicate groups
79+
rg_od_analysis_df = rows_to_replicate_groups(od_analysis_initial_df, 'od')
80+
81+
# move outside of this module *****
82+
# if conf_dict['fc_raw_log10']:
83+
# fc_meta_df = grab_meta_dataframe(exp_ref, exp_ref_dir)
84+
# rg_fc_meta_df = rows_to_replicate_groups(fc_meta_df, 'fc')
85+
#
86+
# elif not conf_dict['fc_raw_log10']:
87+
# pass
88+
return rg_od_analysis_df
89+
90+
91+
if __name__ == '__main__':
92+
93+
parser = argparse.ArgumentParser()
94+
parser.add_argument('experiment_ref', help='experimental reference from data science table')
95+
parser.add_argument('exp_ref_dir', help='path to experimental reference directory')
96+
parser.add_argument('data_confirm_dict', help='dictionary containing information on available data'
97+
' in experimental reference')
98+
parser.add_argument("output_dir", help="directory where to write the output files")
99+
# parser.add_argument("output_dir", help="directory where to write the output files")
100+
args = parser.parse_args()
101+
arg_exp_ref = args.experiment_ref
102+
arg_exp_ref_dir = args.exp_ref_dir
103+
arg_conf_dict = args.data_confirm_dict
104+
arg_out_dir = args.output_dir
105+
106+
run_od_analysis(arg_exp_ref, arg_exp_ref_dir, arg_conf_dict, arg_out_dir)

0 commit comments

Comments
 (0)