Skip to content
Snippets Groups Projects
Commit 202ae5c7 authored by Venkat Malladi's avatar Venkat Malladi
Browse files

fix syntax.

parent ea30a0c5
Branches
Tags
No related merge requests found
...@@ -47,7 +47,7 @@ def rpkm(peak_file,aln_file,exp_name,columns): ...@@ -47,7 +47,7 @@ def rpkm(peak_file,aln_file,exp_name,columns):
columns.append(exp_name) columns.append(exp_name)
## RPKM = numReads / (geneLength/1000 * totalNumReads/1,000,000 ) ## RPKM = numReads / (geneLength/1000 * totalNumReads/1,000,000 )
peak_counts = peak_file.multi_bam_coverage(bams=[aln_file]) peak_counts = peak_file.multi_bam_coverage(bams=[aln_file])
total_counts = reduce(lambda x, y: x + y, [ int(l.rstrip('\n').split('\t')[2]) for l in pysam.idxstats(aln_file,,split_lines=True))]) total_counts = reduce(lambda x, y: x + y, [ int(l.rstrip('\n').split('\t')[2]) for l in pysam.idxstats(aln_file,split_lines=True)])
rpkm = peak_counts.each(normalized_to_length, 3, float(math.pow(10,9))/total_counts).saveas("test.bed") rpkm = peak_counts.each(normalized_to_length, 3, float(math.pow(10,9))/total_counts).saveas("test.bed")
rpkm_df = rpkm.to_dataframe() rpkm_df = rpkm.to_dataframe()
#os.remove('test.bed') #os.remove('test.bed')
...@@ -61,7 +61,7 @@ def rpkm_strand(peak_file,aln_file,exp_name,columns): ...@@ -61,7 +61,7 @@ def rpkm_strand(peak_file,aln_file,exp_name,columns):
columns.append(exp_name) columns.append(exp_name)
## RPKM = numReads / (geneLength/1000 * totalNumReads/1,000,000 ) ## RPKM = numReads / (geneLength/1000 * totalNumReads/1,000,000 )
peak_counts = peak_file.multi_bam_coverage(bams=[aln_file],s=True) peak_counts = peak_file.multi_bam_coverage(bams=[aln_file],s=True)
total_counts = reduce(lambda x, y: x + y, [ int(l.rstrip('\n').split('\t')[2]) for l in pysam.idxstats(aln_file,,split_lines=True))]) total_counts = reduce(lambda x, y: x + y, [ int(l.rstrip('\n').split('\t')[2]) for l in pysam.idxstats(aln_file,split_lines=True)])
rpkm = peak_counts.each(normalized_to_length, 6, float(math.pow(10,9))/float(total_counts)).saveas("test.bed") rpkm = peak_counts.each(normalized_to_length, 6, float(math.pow(10,9))/float(total_counts)).saveas("test.bed")
rpkm_df = rpkm.to_dataframe() rpkm_df = rpkm.to_dataframe()
#os.remove('test.bed') #os.remove('test.bed')
......
...@@ -48,7 +48,6 @@ def rpkm(peak_file,aln_file,exp_name,columns): ...@@ -48,7 +48,6 @@ def rpkm(peak_file,aln_file,exp_name,columns):
## RPKM = numReads / (geneLength/1000 * totalNumReads/1,000,000 ) ## RPKM = numReads / (geneLength/1000 * totalNumReads/1,000,000 )
peak_counts = peak_file.multi_bam_coverage(bams=[aln_file]) peak_counts = peak_file.multi_bam_coverage(bams=[aln_file])
total_counts = reduce(lambda x, y: x + y, [ int(l.rstrip('\n').split('\t')[2]) for l in pysam.idxstats(aln_file,split_lines=True)]) total_counts = reduce(lambda x, y: x + y, [ int(l.rstrip('\n').split('\t')[2]) for l in pysam.idxstats(aln_file,split_lines=True)])
print total_counts
rpkm = peak_counts.each(normalized_to_length, 3, float(math.pow(10,9))/total_counts).saveas("test.bed") rpkm = peak_counts.each(normalized_to_length, 3, float(math.pow(10,9))/total_counts).saveas("test.bed")
rpkm_df = rpkm.to_dataframe() rpkm_df = rpkm.to_dataframe()
#os.remove('test.bed') #os.remove('test.bed')
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment