Skip to content

Commit

Permalink
Change mesa to splicedice in .py files, file names and directories
Browse files Browse the repository at this point in the history
I confirmed that these changes do not change results
  • Loading branch information
hbeale committed Oct 8, 2024
1 parent 0f59716 commit aacb926
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 47 deletions.
18 changes: 9 additions & 9 deletions mesa/MESA.py → splicedice/SPLICEDICE.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3

"""
Mutually Exclusive Splicing Analysis (MESA) main quantification step
Mutually Exclusive Splicing Analysis (SPLICEDICE) main quantification step
"""

Expand All @@ -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"):
Expand Down Expand Up @@ -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"""
Expand All @@ -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()
Expand All @@ -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())
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions mesa/__main__.py → splicedice/__main__.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
File renamed without changes.
12 changes: 6 additions & 6 deletions mesa/compareSampleSets.py → splicedice/compareSampleSets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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",
Expand Down Expand Up @@ -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

Expand All @@ -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"]
Expand All @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions mesa/counts_to_ps.py → splicedice/counts_to_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
8 changes: 4 additions & 4 deletions mesa/findOutliers.py → splicedice/findOutliers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand All @@ -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]
Expand Down
16 changes: 8 additions & 8 deletions mesa/intron_coverage.py → splicedice/intron_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""


Expand All @@ -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)')
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions mesa/make_bed.py → splicedice/make_bed.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions mesa/pairwise_fisher.py → splicedice/pairwise_fisher.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions mesa/select_samples.py → splicedice/select_samples.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
MESA select
SPLICEDICE select
"""

def parseManifest(manifest_filename):
Expand Down Expand Up @@ -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)")
Expand Down
6 changes: 3 additions & 3 deletions mesa/similarity.py → splicedice/similarity.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
MESA similarity
SPLICEDICE similarity
"""

def readVsFile(vs_filename):
Expand Down Expand Up @@ -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")
Expand All @@ -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)
4 changes: 2 additions & 2 deletions mesa/subset.py → splicedice/subset.py
Original file line number Diff line number Diff line change
@@ -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).
"""


Expand All @@ -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')
Expand Down

0 comments on commit aacb926

Please sign in to comment.