Skip to content

Commit

Permalink
Rule 'collect_abundance' for single-read data was ommited.
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunhwan-bcm committed Feb 7, 2019
1 parent 33e89ee commit 600fe2e
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions snakemake/Snakefile.single
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,36 @@ rule run_salmon_gz:
SALMON_PATH + " quant -i {input.idx} -l A -r {input.r} -o {output} -p " + NUM_THREADS + " 2>/dev/null"


rule collect_abundance:
input:
expand(join(OUTPUT_DIR,"{sample_fq}"), sample_fq = SAMPLES_FQ) +
expand(join(OUTPUT_DIR,"{sample_gz}"), sample_gz = SAMPLES_GZ)
output:
join(OUTPUT_DIR,"EXPR.csv")
run:
def get_abundance(fname):
from collections import defaultdict
abundance = defaultdict( float )
with open(fname, "r") as inp:
line = inp.readline()
for line in inp:
line = line.strip().split()
name = line[0]
abundance[name] += float(line[3]) if EXPR_TYPE is "TPM" else float(line[-1])

return abundance

tb = dict()
for file in input:
file = join(file, "quant.sf")
sid = file.split("/")[-2]
tb[sid] = get_abundance(file)

import pandas as pd
with open(str(output), "w") as oup:
oup.write(pd.DataFrame(tb).to_csv(sep=",", index_label="TE"))


rule collect_mappability:
input:
expand(join(OUTPUT_DIR,"{sample_fq}"), sample_fq = SAMPLES_FQ) +
Expand Down

0 comments on commit 600fe2e

Please sign in to comment.