This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(CNAnorm) | |
library(RUnit) | |
#outside R session - convert perl file | |
##perl bam2windows.pl "tumorA.chr4.bam" "normalA.chr4.bam" > perloutput.txt | |
test_counts <- function(chr4data) | |
{ | |
test_indices <- c(8000001, 8010001,10000001 , 10010001, 1000001) | |
test_res <- c(67,62,67,74,47) #from samtools |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Our motivation for this gist comes from the fact that we would like | |
## to check the counts calculated by each of the methods. | |
## Here we provide a simple unitTest which takes as input a GRanges | |
## object which contains the reads from the "tumorA.chr4.bam" file. | |
## we choose 5 regions and get their counts from samtools using a simple | |
## command : | |
## samtools view tumorA.chr4.bam chr4:8000001-8010000 | wc -l 67 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(cn.mops) | |
library(RUnit) | |
tumor_gr <- getReadCountsFromBAM("tumorA.chr4.bam", | |
refSeqName="chr4",WL=10000,mode="unpaired") | |
normal_gr <- getReadCountsFromBAM("normalA.chr4.bam", | |
refSeqName="chr4",WL=10000,mode="unpaired") | |
ref_analysis_norm0 <- referencecn.mops(tumor_gr, normal_gr,norm=0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(GenomicAlignments) | |
library(RUnit) | |
cnv_countOverlaps <- | |
function(bamfilename, chrom, binSize=10000) | |
{ | |
bf <- BamFile(bamfilename) | |
aln<- readGAlignments(bf) | |
sub <- resize(granges(aln), width=1) | |
tiles <- tileGenome(seqlengths(bf), tilewidth=binSize, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plotbinnedCounts <- function(filename, tumor, normal, ylim ) | |
{ | |
y1 <- tumor | |
y2 <- normal | |
png(file= filename, bg="white") | |
plot( y1, | |
col="red", | |
xlab= "bins", | |
ylab =" reads", | |
ylim =ylim ) |