[Patchwork-commits] r41 - pkg/patchwork/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Dec 7 17:47:12 CET 2011
Author: sebastian_d
Date: 2011-12-07 17:47:12 +0100 (Wed, 07 Dec 2011)
New Revision: 41
Modified:
pkg/patchwork/R/karyotype.r
pkg/patchwork/R/karyotype_chroms.r
pkg/patchwork/R/karyotype_chromsCN.r
pkg/patchwork/R/patchwork.CNA.r
pkg/patchwork/R/patchwork.readChroms.r
Log:
Force compatability of chromosome names to suit ideogram. some other fixes.
Modified: pkg/patchwork/R/karyotype.r
===================================================================
--- pkg/patchwork/R/karyotype.r 2011-12-07 10:49:08 UTC (rev 40)
+++ pkg/patchwork/R/karyotype.r 2011-12-07 16:47:12 UTC (rev 41)
@@ -1,5 +1,5 @@
karyotype <- function(chr,start,end,int,ai,chroms,
- name='',xlim=c(-1.02,1.02),ylim=0:1)
+ name='',xlim=c(0,2.4),ylim=c(0.3,1))
{
png(paste(name,'.karyotype.png',sep=''),width=1300,height=1300)
@@ -11,8 +11,7 @@
#substitute ideogram chr names with chroms-object chr names
# so it will work independent of chr field name.
-
- ideogram$chr = chroms
+ #ideogram = merge(chroms,ideogram,all=F,by=1)
colors_p <- colorRampPalette(c("#6600FF","#9900CC"),space="rgb")
colors_q <- colorRampPalette(c("#CC0099","#CC0000"),space="rgb")
@@ -34,7 +33,7 @@
size[length>10000000]=3
- for (c in chroms)
+ for (c in 1:24)
{
this <- ideogram[ideogram$c==c,]
Modified: pkg/patchwork/R/karyotype_chroms.r
===================================================================
--- pkg/patchwork/R/karyotype_chroms.r 2011-12-07 10:49:08 UTC (rev 40)
+++ pkg/patchwork/R/karyotype_chroms.r 2011-12-07 16:47:12 UTC (rev 41)
@@ -11,7 +11,7 @@
#substitute ideogram chr names with chroms-object chr names
# so it will work independent of chr field name.
- ideogram$chr = chroms
+ #ideogram$chr = chroms
#create a color ramp palette to segue the color scheme for plot.
@@ -33,7 +33,7 @@
size[length>5000000]=3
size[length>10000000]=4
- for (c in chroms)
+ for (c in 1:24)
{
this <- ideogram[ideogram$c==c,]
Modified: pkg/patchwork/R/karyotype_chromsCN.r
===================================================================
--- pkg/patchwork/R/karyotype_chromsCN.r 2011-12-07 10:49:08 UTC (rev 40)
+++ pkg/patchwork/R/karyotype_chromsCN.r 2011-12-07 16:47:12 UTC (rev 41)
@@ -12,10 +12,10 @@
#substitute ideogram chr names with chroms-object chr names
# so it will work independent of chr field name.
- chroms = as.character(unique(schr))
- chroms = chroms[chroms != chroms[grep("M",chroms)]]
+ #chroms = as.character(unique(schr))
+ #chroms = chroms[chroms != chroms[grep("M",chroms)]]
- ideogram$chr = chroms
+ #ideogram$chr = chroms
colors_p <- colorRampPalette(c("#6600FF","#9900CC"),space="rgb")
colors_q <- colorRampPalette(c("#CC0099","#CC0000"),space="rgb")
@@ -37,7 +37,7 @@
size[length>5000000]=3
size[length>10000000]=4
- for (c in chroms)
+ for (c in 1:24)
{
this <- ideogram[ideogram$c==c,]
Modified: pkg/patchwork/R/patchwork.CNA.r
===================================================================
--- pkg/patchwork/R/patchwork.CNA.r 2011-12-07 10:49:08 UTC (rev 40)
+++ pkg/patchwork/R/patchwork.CNA.r 2011-12-07 16:47:12 UTC (rev 41)
@@ -25,9 +25,31 @@
save(alf,file="pile.alleles.Rdata")
}
- chroms=as.character(unique(alf$achr))
- chroms = chroms[chroms != chroms[grep("M",chroms)]]
+ #Generate chroms object depending on the naming in pileup (alf).
+ #either chr1...chr22,chrX,chrY or 1...22,X,Y
+ data(ideogram,package="patchworkData")
+ if(grep("chr",as.character(alf$achr[1])) == 1)
+ {
+ chroms = as.character(unique(ideogram$chr))
+ }
+ else
+ {
+ alf$achr = as.character(alf$achr)
+ for(i in 1:22)
+ {
+ alf$achr[alf$achr == as.character(i)] = paste("chr",as.character(i),sep="")
+ }
+ i = "X"
+ alf$achr[alf$achr == as.character(i)] = paste("chr",as.character(i),sep="")
+ i = "Y"
+ alf$achr[alf$achr == as.character(i)] = paste("chr",as.character(i),sep="")
+ chroms = as.character(unique(ideogram$chr))
+ }
+
+ #relic from using alf as chrom generator.
+ #chroms = chroms[chroms != chroms[grep("M",chroms)]]
+
## Read coverage data. If already done, will load "data.Rdata" instead.
data=NULL
try ( load('data.Rdata'), silent=TRUE )
@@ -67,7 +89,7 @@
kbsegs = NULL
try( load("smoothed.Rdata"), silent=TRUE )
- if(length(kbsegs) == 1)
+ if(length(kbsegs) == 0)
{
#Apply smoothing to the data.
cat("Initiating Smoothing \n")
@@ -76,16 +98,25 @@
cat("Smoothing Complete \n")
}
- #Segment the data.
- cat("Initiating Segmentation \n")
- segs = patchwork.segment(kbsegs,chroms,Alpha,SD)
- cat("Segmentation Complete \n")
+ try( load("Segments.Rdata"), silent=TRUE )
- #Get medians and AI for the segments.
- cat("Initiating Segment data extraction (Medians and AI) \n")
- segs = patchwork.Medians_n_AI(segs,kbsegs,alf)
- save(segs,file="Segments.Rdata")
- cat("Segment data extraction Complete \n \n \n")
+ if(length(segs) == 0)
+ {
+ #Segment the data.
+ cat("Initiating Segmentation \n")
+ segs = patchwork.segment(kbsegs,chroms,Alpha,SD)
+ save(segs,file="Segments.Rdata")
+ cat("Segmentation Complete \n")
+ }
+
+ if(length(segs) == 6)
+ {
+ #Get medians and AI for the segments.
+ cat("Initiating Segment data extraction (Medians and AI) \n")
+ segs = patchwork.Medians_n_AI(segs,kbsegs,alf)
+ save(segs,file="Segments.Rdata")
+ cat("Segment data extraction Complete \n \n \n")
+ }
cat("Saving information objects needed for patchwork.findCNs in findCNs.Rdata \n \n \n")
save(segs,alf,kbsegs,BamFile,file="findCNs.Rdata")
Modified: pkg/patchwork/R/patchwork.readChroms.r
===================================================================
--- pkg/patchwork/R/patchwork.readChroms.r 2011-12-07 10:49:08 UTC (rev 40)
+++ pkg/patchwork/R/patchwork.readChroms.r 2011-12-07 16:47:12 UTC (rev 41)
@@ -15,7 +15,7 @@
#if .python folder exists, delete it.
test = getwd()
try( setwd(".python"),silent=TRUE)
- if(getwd() == paste(test,"/.python",sep=""))
+ if(getwd() != test)
{
setwd("..")
system("rm -r .python")
More information about the Patchwork-commits
mailing list