diff --git a/assets/email_template.html b/assets/email_template.html
index b5c9a7b9..2ff8db51 100644
--- a/assets/email_template.html
+++ b/assets/email_template.html
@@ -4,7 +4,7 @@
-
+
nf-core/scrnaseq Pipeline Report
diff --git a/bin/cellranger_mtx_to_h5ad.py b/bin/cellranger_mtx_to_h5ad.py
index e8eb5b23..84305fa3 100755
--- a/bin/cellranger_mtx_to_h5ad.py
+++ b/bin/cellranger_mtx_to_h5ad.py
@@ -2,7 +2,8 @@
import scanpy as sc
import argparse
-def mtx_to_adata( mtx_h5: str, sample: str, verbose: bool = False ):
+
+def mtx_to_adata(mtx_h5: str, sample: str, verbose: bool = False):
if verbose:
print("Reading in {}".format(mtx_h5))
@@ -19,10 +20,10 @@ def mtx_to_adata( mtx_h5: str, sample: str, verbose: bool = False ):
parser = argparse.ArgumentParser(description="Converts mtx output to h5ad.")
- parser.add_argument("-m", "--mtx", dest="mtx", help="Path to mtx h5 file." )
- parser.add_argument("-v", "--verbose", dest="verbose", help="Toggle verbose messages", default=False )
- parser.add_argument("-s", "--sample", dest="sample", help="Sample name" )
- parser.add_argument("-o", "--out", dest="out", help="Output path." )
+ parser.add_argument("-m", "--mtx", dest="mtx", help="Path to mtx h5 file.")
+ parser.add_argument("-v", "--verbose", dest="verbose", help="Toggle verbose messages", default=False)
+ parser.add_argument("-s", "--sample", dest="sample", help="Sample name")
+ parser.add_argument("-o", "--out", dest="out", help="Output path.")
args = vars(parser.parse_args())
diff --git a/bin/concat_h5ad.py b/bin/concat_h5ad.py
index 29d0037a..9c40ec6f 100755
--- a/bin/concat_h5ad.py
+++ b/bin/concat_h5ad.py
@@ -3,6 +3,7 @@
from pathlib import Path
import argparse
+
def read_samplesheet(samplesheet):
df = pd.read_csv(samplesheet)
df.set_index("sample")
@@ -12,14 +13,15 @@ def read_samplesheet(samplesheet):
# only keep unique values using set()
df = df.groupby(["sample"]).agg(lambda column: ",".join(set(column)))
- return(df)
+ return df
+
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Concatenates h5ad files and merge metadata from samplesheet")
- parser.add_argument("-i", "--input", dest="input", help="Path to samplesheet.csv")
- parser.add_argument("-o", "--out", dest="out", help="Output path.")
+ parser.add_argument("-i", "--input", dest="input", help="Path to samplesheet.csv")
+ parser.add_argument("-o", "--out", dest="out", help="Output path.")
parser.add_argument("-s", "--suffix", dest="suffix", help="Suffix of matrices to remove and get sample name")
args = vars(parser.parse_args())
@@ -28,10 +30,7 @@ def read_samplesheet(samplesheet):
df_samplesheet = read_samplesheet(args["input"])
# find all h5ad and append to dict
- dict_of_h5ad = {
- str(path).replace(args["suffix"], ""): sc.read_h5ad(path)
- for path in Path(".").rglob('*.h5ad')
- }
+ dict_of_h5ad = {str(path).replace(args["suffix"], ""): sc.read_h5ad(path) for path in Path(".").rglob("*.h5ad")}
# concat h5ad files
adata = ad.concat(dict_of_h5ad, label="sample", merge="unique", index_unique="_")
@@ -40,4 +39,4 @@ def read_samplesheet(samplesheet):
adata.obs = adata.obs.join(df_samplesheet, on="sample")
adata.write_h5ad(args["out"], compression="gzip")
- print("Wrote h5ad file to {}".format(args["out"]))
\ No newline at end of file
+ print("Wrote h5ad file to {}".format(args["out"]))
diff --git a/bin/mtx_to_h5ad.py b/bin/mtx_to_h5ad.py
index 2885886e..37d7c1ec 100755
--- a/bin/mtx_to_h5ad.py
+++ b/bin/mtx_to_h5ad.py
@@ -4,15 +4,15 @@
import argparse
-def mtx_to_adata(
- mtx_file: str, barcode_file: str, feature_file: str, sample: str, aligner: str, verbose: bool = False
-):
+def mtx_to_adata(mtx_file: str, barcode_file: str, feature_file: str, sample: str, aligner: str, verbose: bool = False):
if verbose:
print("Reading in {}".format(mtx_file))
adata = sc.read_mtx(mtx_file)
- if aligner == 'star': # for some reason star matrix comes transposed and doesn't fit when values are appended directly
+ if (
+ aligner == "star"
+ ): # for some reason star matrix comes transposed and doesn't fit when values are appended directly
adata = adata.transpose()
adata.obs_names = pd.read_csv(barcode_file, header=None, sep="\t")[0].values
adata.var_names = pd.read_csv(feature_file, header=None, sep="\t")[0].values
@@ -26,9 +26,7 @@ def mtx_to_adata(
parser = argparse.ArgumentParser(description="Converts mtx output to h5ad.")
parser.add_argument("-m", "--mtx", dest="mtx", help="Path to mtx file.")
- parser.add_argument(
- "-v", "--verbose", dest="verbose", help="Toggle verbose messages", default=False
- )
+ parser.add_argument("-v", "--verbose", dest="verbose", help="Toggle verbose messages", default=False)
parser.add_argument("-f", "--feature", dest="feature", help="Path to feature file.")
parser.add_argument("-b", "--barcode", dest="barcode", help="Path to barcode file.")
parser.add_argument("-s", "--sample", dest="sample", help="Sample name")
@@ -38,7 +36,7 @@ def mtx_to_adata(
args = vars(parser.parse_args())
adata = mtx_to_adata(
- args["mtx"], args["barcode"], args["feature"], args["sample"], args["aligner"],verbose=args["verbose"]
+ args["mtx"], args["barcode"], args["feature"], args["sample"], args["aligner"], verbose=args["verbose"]
)
adata.write_h5ad(args["out"], compression="gzip")
diff --git a/bin/t2g.py b/bin/t2g.py
index 6419dd1d..38930cea 100755
--- a/bin/t2g.py
+++ b/bin/t2g.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python
-#This was downloaded on 2019-06-23 from https://github.com/bustools/getting_started/releases/
-#All credit goes to the original authors from the Kallisto/BUStools team!
+# This was downloaded on 2019-06-23 from https://github.com/bustools/getting_started/releases/
+# All credit goes to the original authors from the Kallisto/BUStools team!
# BSD 2-Clause License
#
# Copyright (c) 2017, Nicolas Bray, Harold Pimentel, Páll Melsted and Lior Pachter
@@ -29,43 +29,43 @@
import sys, argparse
-def create_transcript_list(input, use_name = True, use_version = False):
+
+def create_transcript_list(input, use_name=True, use_version=False):
r = {}
for line in input:
- if len(line) == 0 or line[0] == '#':
+ if len(line) == 0 or line[0] == "#":
continue
- l = line.strip().split('\t')
- if l[2] == 'transcript':
+ l = line.strip().split("\t")
+ if l[2] == "transcript":
info = l[8]
d = {}
- for x in info.split('; '):
+ for x in info.split("; "):
x = x.strip()
- p = x.find(' ')
+ p = x.find(" ")
if p == -1:
continue
k = x[:p]
- p = x.find('"',p)
- p2 = x.find('"',p+1)
- v = x[p+1:p2]
+ p = x.find('"', p)
+ p2 = x.find('"', p + 1)
+ v = x[p + 1 : p2]
d[k] = v
-
- if 'transcript_id' not in d or 'gene_id' not in d:
+ if "transcript_id" not in d or "gene_id" not in d:
continue
- tid = d['transcript_id'].split(".")[0]
- gid = d['gene_id'].split(".")[0]
+ tid = d["transcript_id"].split(".")[0]
+ gid = d["gene_id"].split(".")[0]
if use_version:
- if 'transcript_version' not in d or 'gene_version' not in d:
+ if "transcript_version" not in d or "gene_version" not in d:
continue
- tid += '.' + d['transcript_version']
- gid += '.' + d['gene_version']
+ tid += "." + d["transcript_version"]
+ gid += "." + d["gene_version"]
gname = None
if use_name:
- if 'gene_name' not in d:
+ if "gene_name" not in d:
continue
- gname = d['gene_name']
+ gname = d["gene_name"]
if tid in r:
continue
@@ -74,26 +74,27 @@ def create_transcript_list(input, use_name = True, use_version = False):
return r
-
-def print_output(output, r, use_name = True):
+def print_output(output, r, use_name=True):
for tid in r:
if use_name:
- output.write("%s\t%s\t%s\n"%(tid, r[tid][0], r[tid][1]))
+ output.write("%s\t%s\t%s\n" % (tid, r[tid][0], r[tid][1]))
else:
- output.write("%s\t%s\n"%(tid, r[tid][0]))
+ output.write("%s\t%s\n" % (tid, r[tid][0]))
if __name__ == "__main__":
-
- parser = argparse.ArgumentParser(add_help=True, description='Creates transcript to gene info from GTF files\nreads from standard input and writes to standard output')
- parser.add_argument('--use_version', '-v', action='store_true', help='Use version numbers in transcript and gene ids')
- parser.add_argument('--skip_gene_names', '-s', action='store_true', help='Do not output gene names')
+ parser = argparse.ArgumentParser(
+ add_help=True,
+ description="Creates transcript to gene info from GTF files\nreads from standard input and writes to standard output",
+ )
+ parser.add_argument(
+ "--use_version", "-v", action="store_true", help="Use version numbers in transcript and gene ids"
+ )
+ parser.add_argument("--skip_gene_names", "-s", action="store_true", help="Do not output gene names")
args = parser.parse_args()
-
-
input = sys.stdin
- r = create_transcript_list(input, use_name = not args.skip_gene_names, use_version = args.use_version)
+ r = create_transcript_list(input, use_name=not args.skip_gene_names, use_version=args.use_version)
output = sys.stdout
print_output(output, r)