Skip to content

Commit 42bd262

Browse files
authored
Merge pull request #127 from MannLabs/remove_dead_code
Remove orphan functions and dead plotting/utility code
2 parents 7da30a8 + a3ce743 commit 42bd262

17 files changed

Lines changed: 2 additions & 1741 deletions

alphaquant/cluster/outlier_scoring.py

Lines changed: 0 additions & 397 deletions
Large diffs are not rendered by default.

alphaquant/diffquant/diffutils.py

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -56,32 +56,6 @@ def get_samples_used_from_samplemap_df(samplemap_df, cond1, cond2):
5656
samples_c2 = samplemap_df[[cond2 == x for x in samplemap_df["condition"]]]["sample"]
5757
return list(samples_c1), list(samples_c2)
5858

59-
def get_all_samples_from_samplemap_df(samplemap_df):
60-
return list(samplemap_df["sample"])
61-
62-
# Cell
63-
import pandas as pd
64-
65-
def get_samplenames_from_input_df(data):
66-
"""extracts the names of the samples of the AQ input dataframe"""
67-
names = list(data.columns)
68-
names.remove('protein')
69-
names.remove(QUANT_ID)
70-
return names
71-
72-
# Cell
73-
import numpy as np
74-
def filter_df_to_min_valid_values(quant_df_wideformat, samples_c1, samples_c2, min_valid_values):
75-
"""filters dataframe in alphaquant format such that each column has a minimum number of replicates
76-
"""
77-
quant_df_wideformat = quant_df_wideformat.replace(0, np.nan)
78-
df_c1_min_valid_values = quant_df_wideformat[samples_c1].dropna(thresh = min_valid_values, axis = 0)
79-
df_c2_min_valid_values = quant_df_wideformat[samples_c2].dropna(thresh = min_valid_values, axis = 0)
80-
idxs_both = df_c1_min_valid_values.index.intersection(df_c2_min_valid_values.index)
81-
quant_df_reduced = quant_df_wideformat.iloc[idxs_both].reset_index()
82-
return quant_df_reduced
83-
84-
8559
# Cell
8660
def get_condpairname(condpair):
8761
return f"{condpair[0]}_VS_{condpair[1]}"
@@ -102,39 +76,6 @@ def make_dir_w_existcheck(dir):
10276
if not os.path.exists(dir):
10377
os.makedirs(dir)
10478

105-
# Cell
106-
import os
107-
def get_results_plot_dir_condpair(results_dir, condpair):
108-
results_dir_plots = f"{results_dir}/{condpair}_plots"
109-
make_dir_w_existcheck(results_dir_plots)
110-
return results_dir_plots
111-
112-
# Cell
113-
def get_middle_elem(sorted_list):
114-
nvals = len(sorted_list)
115-
if nvals==1:
116-
return sorted_list[0]
117-
middle_idx = nvals//2
118-
if nvals%2==1:
119-
return sorted_list[middle_idx]
120-
return 0.5* (sorted_list[middle_idx] + sorted_list[middle_idx-1])
121-
122-
# Cell
123-
import numpy as np
124-
def get_nonna_array(array_w_nas):
125-
res = []
126-
isnan_arr = np.isnan(array_w_nas)
127-
128-
for idx in range(len(array_w_nas)):
129-
sub_res = []
130-
sub_array = array_w_nas[idx]
131-
na_array = isnan_arr[idx]
132-
for idx2 in range(len(sub_array)):
133-
if not na_array[idx2]:
134-
sub_res.append(sub_array[idx2])
135-
res.append(np.array(sub_res))
136-
return np.array(res)
137-
13879
# Cell
13980
import numpy as np
14081
def get_non_nas_from_pd_df(df):
@@ -152,12 +93,6 @@ def get_ionints_from_pd_df(df):
15293
}
15394

15495
# Cell
155-
def invert_dictionary(my_map):
156-
inv_map = {}
157-
for k, v in my_map.items():
158-
inv_map[v] = inv_map.get(v, []) + [k]
159-
return inv_map
160-
16196
from collections import defaultdict
16297
def invert_tuple_list_w_nonunique_values(tuple_list):
16398
inverted_dict = defaultdict(list)
@@ -373,20 +308,6 @@ def get_path_to_unformatted_file(input_file_name):
373308

374309

375310

376-
# Cell
377-
378-
# Cell
379-
import os
380-
def check_for_processed_runs_in_results_folder(results_folder):
381-
contained_condpairs = []
382-
folder_files = os.listdir(results_folder)
383-
result_files = list(filter(lambda x: "results.tsv" in x ,folder_files))
384-
for result_file in result_files:
385-
res_name = result_file.replace(".results.tsv", "")
386-
if ((f"{res_name}.normed.tsv" in folder_files) and (f"{res_name}.results.ions.tsv" in folder_files)):
387-
contained_condpairs.append(res_name)
388-
return contained_condpairs
389-
390311
# Cell
391312
import pandas as pd
392313
import os

alphaquant/multicond/diffresults_handling.py

Lines changed: 0 additions & 128 deletions
This file was deleted.

alphaquant/norm/normalization.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,6 @@ def determine_anchor_and_shift_sample(sample2counts, i_min, j_min, min_distance)
136136
flip = 1 if anchor_idx == i_min else -1
137137
return anchor_idx, shift_idx, flip*min_distance
138138

139-
# Cell
140-
def shift_samples(samples, sampleidx2anchoridx, sample2shift):
141-
for sample_idx in range(samples.shape[0]):
142-
samples[sample_idx] = samples[sample_idx]+get_total_shift(sampleidx2anchoridx, sample2shift, sample_idx)
143-
144139
# Cell
145140
def get_total_shift(sampleidx2anchoridx, sample2shift,sample_idx):
146141

0 commit comments

Comments
 (0)