Skip to content

Commit

Permalink
check strand specificity in each drop group as opposed to all samples
Browse files Browse the repository at this point in the history
  • Loading branch information
AtaJadidAhari committed Jul 29, 2024
1 parent 122aaa5 commit 5f07519
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
4 changes: 0 additions & 4 deletions drop/config/SampleAnnotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ def parse(self, sep='\t'):

annotationTable = pd.read_csv(self.file, sep=sep, index_col=False)

# FRASER cannot handle a mixture of stranded and unstranded samples, raise error in such cases
if (annotationTable['STRAND'] == 'no').any() & ((annotationTable['STRAND'] == 'reverse').any() | (annotationTable['STRAND'] == 'yes').any()):
raise ValueError("Data contains a mix of stranded and unstranded samples. Please analyze them separately.\n")

if annotationTable['STRAND'].isnull().values.any():
raise ValueError("STRAND is not provided for some samples. All samples should have STRAND value in the sample annotation file.\n")

Expand Down
17 changes: 15 additions & 2 deletions drop/config/submodules/AberrantSplicing.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ def __init__(self, config, sampleAnnotation, processedDataDir, processedResultsD
if len(set(self.rnaIDs[g]) & set(self.rnaExIDs[g])) > 0:
raise ValueError(f"{set(self.rnaIDs[g]) & set(self.extRnaIDs[g])} has both BAM and external count file \
please fix in sample annotation table to only have either external count or BAM processing\n")

all_ids = self.sampleAnnotation.subsetGroups(self.groups, assay=["RNA", "SPLICE_COUNT"])
self.checkSubset(all_ids)

self.checkStrandSpecificity()

def setDefaultKeys(self, dict_):
super().setDefaultKeys(dict_)
setKey = utils.setKey
Expand Down Expand Up @@ -109,3 +110,15 @@ def getPsiTypeAssay(self):
if(fraser_version == "FRASER2"):
return "jaccard"
return "theta"

def checkStrandSpecificity(self):
"""
FRASER cannot handle a mixture of stranded and unstranded samples
raises an error in such cases
"""

for drop_group in self.groups:
drop_group_annotation = self.sampleAnnotation.getIDsByGroup(drop_group)
drop_group_annotation = self.sampleAnnotation.subsetSampleAnnotation("RNA_ID", drop_group_annotation)
if (drop_group_annotation['STRAND'] == 'no').any() & ((drop_group_annotation['STRAND'] == 'reverse').any() | (drop_group_annotation['STRAND'] == 'yes').any()):
raise ValueError(f"Data contains a mix of stranded and unstranded samples in group: {drop_group}. Please analyze them separately.\n")

0 comments on commit 5f07519

Please sign in to comment.