From aacb92644f2062b8105a6379577c79c483d33d40 Mon Sep 17 00:00:00 2001 From: hbeale Date: Tue, 8 Oct 2024 13:46:36 -0700 Subject: [PATCH] Change mesa to splicedice in .py files, file names and directories I confirmed that these changes do not change results --- mesa/MESA.py => splicedice/SPLICEDICE.py | 18 +++++++++--------- {mesa => splicedice}/__init__.py | 0 {mesa => splicedice}/__main__.py | 8 ++++---- {mesa => splicedice}/bam_to_junc_bed.py | 0 {mesa => splicedice}/compareSampleSets.py | 12 ++++++------ {mesa => splicedice}/counts_to_ps.py | 4 ++-- {mesa => splicedice}/findOutliers.py | 8 ++++---- {mesa => splicedice}/intron_coverage.py | 16 ++++++++-------- {mesa => splicedice}/ir_table.py | 0 {mesa => splicedice}/make_bed.py | 6 +++--- {mesa => splicedice}/pairwise_fisher.py | 6 +++--- {mesa => splicedice}/select_samples.py | 6 +++--- {mesa => splicedice}/similarity.py | 6 +++--- {mesa => splicedice}/subset.py | 4 ++-- 14 files changed, 47 insertions(+), 47 deletions(-) rename mesa/MESA.py => splicedice/SPLICEDICE.py (97%) rename {mesa => splicedice}/__init__.py (100%) rename {mesa => splicedice}/__main__.py (88%) rename {mesa => splicedice}/bam_to_junc_bed.py (100%) rename {mesa => splicedice}/compareSampleSets.py (96%) rename {mesa => splicedice}/counts_to_ps.py (96%) rename {mesa => splicedice}/findOutliers.py (95%) rename {mesa => splicedice}/intron_coverage.py (94%) rename {mesa => splicedice}/ir_table.py (100%) rename {mesa => splicedice}/make_bed.py (91%) rename {mesa => splicedice}/pairwise_fisher.py (98%) rename {mesa => splicedice}/select_samples.py (95%) rename {mesa => splicedice}/similarity.py (95%) rename {mesa => splicedice}/subset.py (96%) diff --git a/mesa/MESA.py b/splicedice/SPLICEDICE.py similarity index 97% rename from mesa/MESA.py rename to splicedice/SPLICEDICE.py index 63837f8..921172b 100644 --- a/mesa/MESA.py +++ b/splicedice/SPLICEDICE.py @@ -1,7 +1,7 @@ #!/usr/bin/env python3 """ -Mutually Exclusive Splicing Analysis (MESA) main quantification step +Mutually Exclusive Splicing Analysis (SPLICEDICE) main quantification step """ @@ -25,7 +25,7 @@ def __init__(self,manifestLine): with open(self.filename) as bedfile: info = bedfile.readline().split('\t')[3].split(';') if info[0].startswith("e:") and info[1].startswith("o:"): - self.type = "mesabed" + self.type = "splicedicebed" elif self.filename.upper().endswith("SJ.OUT.TAB"): self.type = "SJ" elif self.filename.upper().endswith(".BAM"): @@ -68,7 +68,7 @@ def check(self): -class MESA: +class SPLICEDICE: """Main algorithm for Mutually Exclusive Splicing Analysis""" def __init__(self,manifestFilename,outputPrefix,args): """Call methods to get input, process, and write output""" @@ -79,7 +79,7 @@ def __init__(self,manifestFilename,outputPrefix,args): self.manifestFilename = manifestFilename self.outputPrefix = outputPrefix - # Construct MESA + # Construct SPLICEDICE timer = Timer() print("Parsing manifest...") self.manifest = self.parseManifest() @@ -106,7 +106,7 @@ def __init__(self,manifestFilename,outputPrefix,args): self.writeJunctionBed() print("\tDone",timer.check()) - # Quantify MESA + # Quantify SPLICEDICE print("Gathering junction counts...") self.counts, self.low = self.getJunctionCounts() print("\tDone",timer.check()) @@ -180,7 +180,7 @@ def getAllJunctions(self): intronMotif in validMotifs): junctions.add((chromosome,left,right,strand)) - elif sample.type == "mesabed": + elif sample.type == "splicedicebed": for line in junctionFile: row = line.rstrip().split("\t") @@ -263,7 +263,7 @@ def getJunctionCounts(self): with open(sample.filename,"r") as sampleFile: - if sample.type == "bed" or sample.type == "mesabed" or sample.type == "leafcutter": + if sample.type == "bed" or sample.type == "splicedicebed" or sample.type == "leafcutter": for line in sampleFile: row = line.rstrip().split("\t") @@ -402,11 +402,11 @@ def add_parser(parser): help="Shannon's diversity index associated with a junction, minumum required for inclusion [Default 1]") def run_with(args): - """ Main program which calls MESA algorithm class""" + """ Main program which calls SPLICEDICE algorithm class""" manifestFilename = args.manifest outputPrefix = args.output_prefix - MESA(manifestFilename,outputPrefix,args) + SPLICEDICE(manifestFilename,outputPrefix,args) if __name__ == "__main__": import argparse diff --git a/mesa/__init__.py b/splicedice/__init__.py similarity index 100% rename from mesa/__init__.py rename to splicedice/__init__.py diff --git a/mesa/__main__.py b/splicedice/__main__.py similarity index 88% rename from mesa/__main__.py rename to splicedice/__main__.py index ed4e04c..97e6995 100644 --- a/mesa/__main__.py +++ b/splicedice/__main__.py @@ -1,8 +1,8 @@ #!/usr/bin/env python3 -"""This script is the main entry point for the different MESA commands.""" +"""This script is the main entry point for the different SPLICEDICE commands.""" import argparse -from . import MESA as quant +from . import SPLICEDICE as quant from . import bam_to_junc_bed as bjb from . import pairwise_fisher as pf from . import compareSampleSets as css @@ -17,9 +17,9 @@ def add_cmd(name, arg_parser_fn, run_with, subparser): """Adds a subparser command to the parser. name is a string that denotes name of the command being added. This function helps a) simplify adding new - commands to the mesa tool b) also allows for using each python file as its + commands to the splicedice tool b) also allows for using each python file as its own script instead of relying on the __main__.py parser solely. - ie allows for `mesa quant` and `python quantMESA.py` to be easier to use. + ie allows for `splicedice quant` and `python quantSPLICEDICE.py` to be easier to use. arg_parser_fn is a function that takes a subparser and adds arguments based on the command. Modules typically expose an add_parser() function that does diff --git a/mesa/bam_to_junc_bed.py b/splicedice/bam_to_junc_bed.py similarity index 100% rename from mesa/bam_to_junc_bed.py rename to splicedice/bam_to_junc_bed.py diff --git a/mesa/compareSampleSets.py b/splicedice/compareSampleSets.py similarity index 96% rename from mesa/compareSampleSets.py rename to splicedice/compareSampleSets.py index 91967f9..cbc5155 100644 --- a/mesa/compareSampleSets.py +++ b/splicedice/compareSampleSets.py @@ -104,7 +104,7 @@ def getColIndexFromArray(x, y): def returnSamplesFromManifest(x): """ - reads in mesa formatted manifest + reads in splicedice formatted manifest returns list of samples """ s = list() @@ -123,10 +123,10 @@ def returnSamplesFromManifest(x): def add_parser(parser): parser.add_argument( - "--psiMESA", + "--psiSPLICEDICE", type=str, required=True, - help="Compressed NPZ formatted PSI matrix from 'mesa quant'.", + help="Compressed NPZ formatted PSI matrix from 'splicedice quant'.", ) parser.add_argument( "-m1", @@ -167,7 +167,7 @@ def run_with(args): Values are assumed to not be normall distributed, thus we invoke the wilcoxon ranksum test as the statistical analysis. """ - pmesa = args.psiMESA + psplicedice = args.psiSPLICEDICE group1 = args.manifest1 group2 = args.manifest2 @@ -183,7 +183,7 @@ def run_with(args): sys.exit(1) # load psi - #data = loadNPZ(pmesa) + #data = loadNPZ(psplicedice) # table has 3 arrays, cols, rows and data #cols, rows, matrix = data["cols"], data["rows"], data["data"] @@ -192,7 +192,7 @@ def run_with(args): ###### rows = [] data = [] - with open(pmesa) as tsv: + with open(psplicedice) as tsv: headers = tsv.readline().strip().split('\t')[1:] for line in tsv: row = line.strip().split('\t') diff --git a/mesa/counts_to_ps.py b/splicedice/counts_to_ps.py similarity index 96% rename from mesa/counts_to_ps.py rename to splicedice/counts_to_ps.py index 149d798..87d579a 100644 --- a/mesa/counts_to_ps.py +++ b/splicedice/counts_to_ps.py @@ -82,13 +82,13 @@ def add_parser(parser): """ """ parser.add_argument("--clusters","-c", action="store",default=None, - help="allClusters.tsv file from MESA") + help="allClusters.tsv file from SPLICEDICE") parser.add_argument("--recluster","-r", action="store_true", help="Determine clusters from splice junctions in counts file") parser.add_argument("--inclusion_counts","-i", action="store",required=True, - help="inclusionCounts.tsv file from MESA") + help="inclusionCounts.tsv file from SPLICEDICE") parser.add_argument("--output_prefix","-o", action="store",required=True, help="output filename path and prefix") diff --git a/mesa/findOutliers.py b/splicedice/findOutliers.py similarity index 95% rename from mesa/findOutliers.py rename to splicedice/findOutliers.py index 90fd2a4..28ff3b9 100644 --- a/mesa/findOutliers.py +++ b/splicedice/findOutliers.py @@ -28,11 +28,11 @@ def add_parser(parser): """Add command line argument parser for findOutliers module""" parser.add_argument( - "--psiMESA", + "--psiSPLICEDICE", type=str, action="store", required=True, - help="Compressed NPZ formatted PSI matrix from quantMESA.", + help="Compressed NPZ formatted PSI matrix from quantSPLICEDICE.", ) parser.add_argument( @@ -91,7 +91,7 @@ def loadNPZ(x): ######################################################################## def run_with(args): - pmesa = args.psiMESA + psplicedice = args.psiSPLICEDICE man = args.manifest null = args.nullMan zthresh = args.outlierCutoff @@ -114,7 +114,7 @@ def run_with(args): ) sys.exit(1) # load psi - data = loadNPZ(pmesa) + data = loadNPZ(psplicedice) mSamps, mEvents, matrix = data["cols"], data["rows"], data["data"] # m is for matrix nullIndices = np.argwhere(np.isin(mSamps, nullSamps))[:, 0] diff --git a/mesa/intron_coverage.py b/splicedice/intron_coverage.py similarity index 94% rename from mesa/intron_coverage.py rename to splicedice/intron_coverage.py index ebf4f13..24c38c1 100644 --- a/mesa/intron_coverage.py +++ b/splicedice/intron_coverage.py @@ -2,7 +2,7 @@ """ Process alignment files (BAMs) to determine coverage at positions along introns, as defined in junction file. -python3 intron_coverage.py -b bam_manifest.tsv -m output_allPSI.tsv -j mesa_junctions.bed +python3 intron_coverage.py -b bam_manifest.tsv -m output_allPSI.tsv -j splicedice_junctions.bed """ @@ -20,12 +20,12 @@ def add_parser(parser): parser.add_argument('-b', '--bamManifest', action = 'store', required=True, help='tab-separated list of bam files for all samples') - parser.add_argument('-m', '--mesaTable', + parser.add_argument('-m', '--splicediceTable', action = 'store', required=True, - help='mesa allPSI.tsv output from mesa') + help='splicedice allPSI.tsv output from splicedice') parser.add_argument('-j', '--junctionFile', action = 'store', required=True, - help='mesa junction.bed output from mesa') + help='splicedice junction.bed output from splicedice') parser.add_argument('-s', '--binSize', action='store', default=500000, type=int, help='chromosome bins for processing (must exceed intron length)') @@ -38,12 +38,12 @@ def add_parser(parser): help='directory for outputting intron coverage count files') class IntronCoverage(): - def __init__(self, manifest,mesa,junctionFile,binSize,numThreads,outputDir): + def __init__(self, manifest,splicedice,junctionFile,binSize,numThreads,outputDir): """ Instantiate object attributes """ self.manifest = manifest - self.mesa = mesa + self.splicedice = splicedice self.junctionFilename = junctionFile self.binSize = binSize self.numThreads = numThreads @@ -249,7 +249,7 @@ def run_with(args): start_time = time.time() manifest = args.bamManifest - mesa = args.mesaTable + splicedice = args.splicediceTable junctionFile = args.junctionFile binSize = args.binSize numThreads = args.numThreads @@ -258,7 +258,7 @@ def run_with(args): if not os.path.isdir(outputDir): os.mkdir(outputDir) - intronCoverage = IntronCoverage(manifest,mesa,junctionFile,binSize,numThreads,outputDir) + intronCoverage = IntronCoverage(manifest,splicedice,junctionFile,binSize,numThreads,outputDir) intronCoverage.parseManifest() intronCoverage.getIntronPercentiles() intronCoverage.getCoveragePool() diff --git a/mesa/ir_table.py b/splicedice/ir_table.py similarity index 100% rename from mesa/ir_table.py rename to splicedice/ir_table.py diff --git a/mesa/make_bed.py b/splicedice/make_bed.py similarity index 91% rename from mesa/make_bed.py rename to splicedice/make_bed.py index 3527372..d8ca3c1 100644 --- a/mesa/make_bed.py +++ b/splicedice/make_bed.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ -Make a bed file from MESA's compare_sample_sets output file +Make a bed file from SPLICEDICE's compare_sample_sets output file """ def deltaColor(delta): @@ -38,13 +38,13 @@ def makeBed(bedfilename,vsfilename,use_corrected,alpha): def get_args(): import argparse - parser = argparse.ArgumentParser(description='Make bed file from output of mesa compare_sample_sets') + parser = argparse.ArgumentParser(description='Make bed file from output of splicedice compare_sample_sets') parser.add_argument('--alpha','-a',default=0.05, help='Significance threshold for filtering based on p-value. Default 0.05') parser.add_argument('--use_corrected','-c',action='store_true', help='Flag to use corrected p-value in filtering and output label. Default uses raw p-value') parser.add_argument('--input','-i',required=True, - help='Comparison file from mesa compare_sample_sets') + help='Comparison file from splicedice compare_sample_sets') parser.add_argument('--output','-o',required=True, help='Output filename') return parser.parse_args() diff --git a/mesa/pairwise_fisher.py b/splicedice/pairwise_fisher.py similarity index 98% rename from mesa/pairwise_fisher.py rename to splicedice/pairwise_fisher.py index f5aab92..deaf8d5 100644 --- a/mesa/pairwise_fisher.py +++ b/splicedice/pairwise_fisher.py @@ -70,10 +70,10 @@ def getEventCounts(filename, filter_list=None): def add_parser(parser): parser.add_argument( - "--inclusionMESA", + "--inclusionSPLICEDICE", type=str, required=True, - help="Compressed NPZ formatted Inclusion count matrix from quantMESA.", + help="Compressed NPZ formatted Inclusion count matrix from quantSPLICEDICE.", ) parser.add_argument( @@ -120,7 +120,7 @@ def run_with(args): from statsmodels.stats.multitest import multipletests # Input file arguments - inclusionCounts = args.inclusionMESA + inclusionCounts = args.inclusionSPLICEDICE allClusters = args.clusters outfilename = args.output diff --git a/mesa/select_samples.py b/splicedice/select_samples.py similarity index 95% rename from mesa/select_samples.py rename to splicedice/select_samples.py index a3049b9..e1a66f6 100644 --- a/mesa/select_samples.py +++ b/splicedice/select_samples.py @@ -1,5 +1,5 @@ """ -MESA select +SPLICEDICE select """ def parseManifest(manifest_filename): @@ -64,10 +64,10 @@ def add_parser(parser): """ """ parser.add_argument("--allps1","-a1", action="store", - help="First allPS file output from mesa quant") + help="First allPS file output from splicedice quant") parser.add_argument("--allps2","-a2", action="store", - help="Second allPS file output from mesa quant") + help="Second allPS file output from splicedice quant") parser.add_argument("--manifest","-m", action="store", help="File with list of allPS file paths (supercedes allPS1 and allPS2)") diff --git a/mesa/similarity.py b/splicedice/similarity.py similarity index 95% rename from mesa/similarity.py rename to splicedice/similarity.py index a904c24..6bc6a99 100644 --- a/mesa/similarity.py +++ b/splicedice/similarity.py @@ -1,5 +1,5 @@ """ -MESA similarity +SPLICEDICE similarity """ def readVsFile(vs_filename): @@ -75,7 +75,7 @@ def add_parser(parser): help="Output table from compare_sample_sets") parser.add_argument("--allps","-a", action="store",required=True, - help="Allps table from mesa quant") + help="Allps table from splicedice quant") parser.add_argument("--output","-o", action="store",required=True, help="Output filename") @@ -99,7 +99,7 @@ def run_with(args): if __name__ == "__main__": import argparse - parser = argparse.ArgumentParser(description='Scores similarity of samples to a condition from mesa compare_sample_sets.') + parser = argparse.ArgumentParser(description='Scores similarity of samples to a condition from splicedice compare_sample_sets.') add_parser(parser) args = parser.parse_args() run_with(args) diff --git a/mesa/subset.py b/splicedice/subset.py similarity index 96% rename from mesa/subset.py rename to splicedice/subset.py index fe5e178..fe346ad 100644 --- a/mesa/subset.py +++ b/splicedice/subset.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ -For subsetting a percent-spliced table output from mesa (filename ending with allPS.tsv). +For subsetting a percent-spliced table output from splicedice (filename ending with allPS.tsv). """ @@ -19,7 +19,7 @@ def add_parser(parser): help='Text file of samples to include in subset, one per line [Default includes all samples]') parser.add_argument('-i', '--inputFilename', required=True, - help='Table of PS values from MESA quant (*_allPS.tsv)') + help='Table of PS values from SPLICEDICE quant (*_allPS.tsv)') parser.add_argument('-o', '--outputFilename', required=True, help='Table of PS values for selected samples and junctions')