Skip to content

Commit ac204e3

Browse files
committed
v4.4.3
1 parent 64d0677 commit ac204e3

File tree

6 files changed

+32
-9
lines changed

6 files changed

+32
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
CARMEN is a diagnostic tool designed for surveillance purposes. Below are the instructions to complete your CARMEN analysis.
33

44
## Software Version
5-
When cloning this repository, you will be using software version 4.4.2.
5+
When cloning this repository, you will be using software version 4.4.3.
66

77
## Overview
88
At this point, you have ran the $Standard\ BioTools\ Dynamic\ Array^{TM}$ IFC (integrated fluidic circuit) on the $Standard\ BioTools\ Biomark^{TM}$ instrument and have completed the experimental portion of CARMEN. In running this code, you will be able to complete the data analysis portion of CARMEN and generate both binary positive/negative and quantitative signal output of your diagnostic assay.

analyze_run.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
######################################################################################################################################################
5151
# assign software version
52-
software_version = '4.4.2'
52+
software_version = '4.4.3'
5353

5454
######################################################################################################################################################
5555
# data loading
@@ -843,6 +843,9 @@
843843
fl_rounded_ntc_thresholds_output = flagged_files[3] # NTC_thresholds
844844
fl_t13_hit_binary_output = flagged_files[4] # 't13__{barcode_assignment}_hit_binary
845845

846+
# any last formatting changes to dataframes
847+
fl_t13_hit_binary_output.columns = fl_t13_hit_binary_output.columns.str.upper()
848+
846849
# SAVE all the files to their respective output folders
847850
sheet_names = [
848851
"CARMEN_Hit_Results",

binary_results.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ def __init__(self):
1313

1414
# positive = 1, negative = 0
1515
def hit_numeric_conv(self, binary_t13_hit_df):
16-
binary_t13_hit_df = binary_t13_hit_df.replace(['POSITIVE', 'NEGATIVE'], [1,0])
16+
#deprecated approaches
17+
#binary_t13_hit_df = binary_t13_hit_df.replace(['POSITIVE', 'NEGATIVE'], [1,0])
18+
#binary_t13_hit_df = binary_t13_hit_df.applymap(lambda x: {'POSITIVE': 1, 'NEGATIVE': 0}.get(x, x))
19+
20+
binary_t13_hit_df = binary_t13_hit_df.assign(
21+
**{col: binary_t13_hit_df[col].map({'POSITIVE': 1, 'NEGATIVE': 0}) for col in binary_t13_hit_df.columns}
22+
)
23+
1724
return binary_t13_hit_df
1825

flags.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ def assign_flags(self, fail_nocrRNA_check_df, high_raw_ntc_signal_df, rnasep_df,
1515
files = [t13_hit, t13_quant_norm, pos_samples_df, ntc_thresh, t13_hit_binary] # 0, 1, 2, 3, 4
1616
flagged_files = [] # store modified files after applying flags
1717

18-
### CPC flags
19-
## need to be added to t13_hit_output, rounded_t13_quant_norm, summary_samples_df, ntc_thresholds_output, t13_hit_binary_output
2018
for i, file in enumerate(files):
19+
20+
### CPC flags
21+
## need to be added to t13_hit_output, rounded_t13_quant_norm, summary_samples_df, ntc_thresholds_output, t13_hit_binary_output
2122
flagged_file = file.copy() # work on a copy of the orig file
2223
invalid_assays = [] # track which assays are invalid based on QC3 test results
2324
for row in QC_score_per_assay_df.itertuples():
@@ -78,9 +79,11 @@ def assign_flags(self, fail_nocrRNA_check_df, high_raw_ntc_signal_df, rnasep_df,
7879
processed_samples.add((cont_ntc_sample, cont_ntc_assay))
7980
# check if the value is NA (NaN)
8081
if pd.isna(sample_row[assay_col]):
81-
flagged_file.at[idx, assay_col] = '†' # only dagger if value is NA
82+
flagged_file.loc[idx, assay_col] = '†' # only dagger if value is NA
8283
else:
83-
flagged_file.at[idx, assay_col] = f"{sample_row[assay_col]}†" # add dagger to the value
84+
flagged_file[assay_col] = flagged_file[assay_col].astype(str)
85+
#flagged_file.at[idx, assay_col] = str(flagged_file.at[idx, assay_col])
86+
flagged_file.loc[idx, assay_col] = f"{sample_row[assay_col]}†" # add dagger to the value
8487

8588
for _, row in high_raw_ntc_signal_df.iterrows():
8689
for col in high_raw_ntc_signal_df.columns:

median_frame.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,22 @@ def create_median(self, signal_norm):
1515
# create a list containing t1 thru t13
1616
t_names = [col for col in signal_norm.columns if col.startswith('t')]
1717

18+
# initialize a dictionary
1819
med_frames = {}
19-
for name in t_names:
20+
# for each timepoint
21+
for name in t_names:
22+
# groups signal_norm by assay and sample
23+
# in groupby, pandas automatically sorts the assay col in alpha order
24+
# selects the column for the specific timepoint
25+
# calculate the median value for each unique group (assay and sample) for that specific timepoint
26+
# finally .unstack() unstacks the sample (outer layer of grouping), so the samples are columns and assays are rows
2027
time_med = signal_norm.groupby(['assay', 'sample'])[name].median().unstack()
28+
# clean up the names of index and columns
2129
time_med.index.names=['']
2230
time_med.columns.names=['']
31+
# transpose time_med so the rows are samples and the columns are assays
2332
time_med_transposed = time_med.transpose()
33+
# store transposed df for each timepoint into dictionary med_frames with timepoint as the key
2434
med_frames[name] = time_med_transposed
2535

2636
return med_frames

t13_plotting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def t13_plt_heatmap(self, tgap, barcode_number, df, sample_list, assay_list, tp,
241241
ha='left', fontsize=12, style='italic')
242242

243243
# plot *** on x-axis that contains Invalid Samples
244-
if invalid_samples:
244+
if invalid_samples.size>0:
245245
invalid_samples = [sample.upper() for sample in invalid_samples]
246246
"""
247247
asterisk3_labels = [label + '***' if label in invalid_samples else label for label in frame2.columns]

0 commit comments

Comments
 (0)