Skip to content

Commit

Permalink
added s_id to filter_df(): ('data_id-time-rep')
Browse files Browse the repository at this point in the history
  • Loading branch information
tuttlelm authored Aug 22, 2024
1 parent c2df68f commit 2c16165
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion pyhxexpress/hxex_updating.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def makelist(thing):
return thing

def filter_df(metadf=pd.DataFrame(),samples=None,range=None,peptide_ranges=None,
charge=None,index=None,timept=None,timeidx=None,peptides=None,rep=None,data_ids=None,quiet=True):
charge=None,index=None,timept=None,timeidx=None,peptides=None,rep=None,data_ids=None,s_ids=None,quiet=True):
''' Utility function to Filter metadf (or any other dataframe) based on user specified values
samples = ['sample1','sample2'] or 'sample1'
range = [start,end]
Expand Down Expand Up @@ -331,6 +331,14 @@ def filter_df(metadf=pd.DataFrame(),samples=None,range=None,peptide_ranges=None,
if not filtered.empty and (rep or rep == 0):
try: filtered = filtered[filtered['rep'].isin(makelist(rep))]
except: print("no column named rep")

if not filtered.empty and s_ids:
s_ids = makelist(s_ids)
for s_id in s_ids:
d, t, r = [float(s) for s in s_id.split('-')]
try:
filtered = filtered[(filtered['data_id'] == d) & (filtered['time'] == t) & (filtered['rep']==r)]
except: print("no s_id",s_id)

if quiet == False:
print("Dataframe filtered to",len(filtered),"from",len(metadf),"total entries")
Expand Down

0 comments on commit 2c16165

Please sign in to comment.