[Patchwork-commits] r28 - pkg/patchwork/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Nov 25 13:50:34 CET 2011
Author: sebastian_d
Date: 2011-11-25 13:50:34 +0100 (Fri, 25 Nov 2011)
New Revision: 28
Modified:
pkg/patchwork/R/patchwork.CNA.r
pkg/patchwork/R/patchwork.applyref.r
pkg/patchwork/R/patchwork.createreference.r
pkg/patchwork/R/patchwork.customsegment.r
pkg/patchwork/R/patchwork.segment.r
Log:
Post talk meeting with Marcus update. Moved pile.allele part to gather correct chroms object information which is dependent on the datas origin. Also in the process of removing custom segmentation and implementing some additional parameters to main function to replace this functionality.
Modified: pkg/patchwork/R/patchwork.CNA.r
===================================================================
--- pkg/patchwork/R/patchwork.CNA.r 2011-11-22 15:58:41 UTC (rev 27)
+++ pkg/patchwork/R/patchwork.CNA.r 2011-11-25 12:50:34 UTC (rev 28)
@@ -1,15 +1,31 @@
-patchwork.CNA <- function(BamFile,Pileup,solid = FALSE,reference = NULL)
+patchwork.CNA <- function(BamFile,Pileup,reference,Alpha=0.0001,SD=1)
{
#Load DNAcopy
- library(DNAcopy)
+ #library(DNAcopy)
#Load data included in package
- packagepath = system.file(package="patchwork")
+ #packagepath = system.file(package="patchwork")
#load(paste(packagepath,"/data/commonSnps132.RData",sep=""))
- load(paste(packagepath,"/data/ideogram.RData",sep=""))
+ #load(paste(packagepath,"/data/ideogram.RData",sep=""))
#load(paste(packagepath,"/data/normaldata.RData",sep=""))
- chroms=as.character(unique(ideogram$chr))
+ #Attempt to read file pile.alleles, incase its already been created.
+ alf = NULL
+ try( load("pile.alleles.Rdata"), silent=TRUE )
+
+ #If it wasnt created, create it using the perl script pile2alleles.pl
+ #which is included in the package. Creates pile.alleles in whichever folder
+ #you are running R from. (getwd())
+ if(length(alf) == 1)
+ {
+ cat("Initiating Allele Data Generation \n")
+ alf = patchwork.alleledata(Pileup)
+ cat("Allele Data Generation Complete \n")
+ save(alf,file="pile.alleles.Rdata")
+ }
+
+ chroms=as.character(unique(alf$achr))
+
## Read coverage data. If already done, will load "data.Rdata" instead.
data=NULL
try ( load('data.Rdata'), silent=TRUE )
@@ -41,38 +57,28 @@
if(length(data) < 9)
{
cat("Initiating Application of Reference \n")
- data = patchwork.applyref(data,solid,reference)
+ data = patchwork.applyref(data,reference)
cat("Application of Reference Complete \n")
save(data,file='data.Rdata')
}
+ kbsegs = NULL
+ try( load("smoothed.Rdata"), silent=TRUE )
- #Apply smoothing to the data.
- cat("Initiating Smoothing \n")
- kbsegs = patchwork.smoothing(data,chroms)
- save(kbsegs,file="smoothed.Rdata")
- cat("Smoothing Complete \n")
+ if(length(kbsegs) == 1)
+ {
+ #Apply smoothing to the data.
+ cat("Initiating Smoothing \n")
+ kbsegs = patchwork.smoothing(data,chroms)
+ save(kbsegs,file="smoothed.Rdata")
+ cat("Smoothing Complete \n")
+ }
#Segment the data.
cat("Initiating Segmentation \n")
- segs = patchwork.segment(kbsegs,chroms)
+ segs = patchwork.segment(kbsegs,chroms,Alpha,SD)
cat("Segmentation Complete \n")
- #Attempt to read file pile.alleles, incase its already been created.
- alf = NULL
- try( load("pile.alleles.Rdata"), silent=TRUE )
-
- #If it wasnt created, create it using the perl script pile2alleles.pl
- #which is included in the package. Creates pile.alleles in whichever folder
- #you are running R from. (getwd())
- if(length(alf) == 1)
- {
- cat("Initiating Allele Data Generation \n")
- alf = patchwork.alleledata(Pileup)
- cat("Allele Data Generation Complete \n")
- save(alf,file="pile.alleles.Rdata")
- }
-
#Get medians and AI for the segments.
cat("Initiating Segment data extraction (Medians and AI) \n")
segs = patchwork.Medians_n_AI(segs,kbsegs,alf)
Modified: pkg/patchwork/R/patchwork.applyref.r
===================================================================
--- pkg/patchwork/R/patchwork.applyref.r 2011-11-22 15:58:41 UTC (rev 27)
+++ pkg/patchwork/R/patchwork.applyref.r 2011-11-25 12:50:34 UTC (rev 28)
@@ -1,4 +1,4 @@
-patchwork.applyref <- function(data,solid,reference=NULL)
+patchwork.applyref <- function(data,reference)
{
#This load shall be changed to read Illumina data as default
@@ -8,22 +8,19 @@
packagepath = system.file(package="patchwork")
#load(paste(packagepath,"/data/commonSnps132.RData",sep=""))
#load(paste(packagepath,"/data/ideogram.RData",sep=""))
- if (is.null(reference))
+
+ if(tolower(reference) == "solid")
{
- if (solid == TRUE)
- {
- load(paste(packagepath,"/data/datasolid.RData",sep=""))
- normaldata = datasolid
- }
- else
- {
- load(paste(packagepath,"/data/datasolexa.RData",sep=""))
- normaldata = datasolexa
- }
+ load(paste(packagepath,"/data/datasolid.RData",sep=""))
+ normaldata = datasolid
+ ifelse(tolower(reference) %in% c("solexa","illumina"))
+ {
+ load(paste(packagepath,"/data/datasolexa.RData",sep=""))
+ normaldata = datasolexa
}
else
{
- normaldata = reference
+ load(reference)
}
## read and apply normal/reference
Modified: pkg/patchwork/R/patchwork.createreference.r
===================================================================
--- pkg/patchwork/R/patchwork.createreference.r 2011-11-22 15:58:41 UTC (rev 27)
+++ pkg/patchwork/R/patchwork.createreference.r 2011-11-25 12:50:34 UTC (rev 28)
@@ -1,4 +1,4 @@
-patchwork.createreference = function(...)
+patchwork.createreference = function(...,output="REFOUT")
{
data=NULL
@@ -57,8 +57,7 @@
}
- cat("Saving to Normal_Reference.Rdata \n")
- save(normaldata,file="Normal_Reference.RData")
+ cat("Saving to ",output,".Rdata \n",sep="")
+ save(normaldata,file=paste(output,".RData",sep=""))
return(normaldata)
-
}
\ No newline at end of file
Modified: pkg/patchwork/R/patchwork.customsegment.r
===================================================================
--- pkg/patchwork/R/patchwork.customsegment.r 2011-11-22 15:58:41 UTC (rev 27)
+++ pkg/patchwork/R/patchwork.customsegment.r 2011-11-25 12:50:34 UTC (rev 28)
@@ -1,4 +1,4 @@
-patchwork.customsegment = function(kbsegs,Alpha = 0.0001,SD=1)
+patchwork.customsegment = function(Alpha = 0.0001,SD=1)
{
#Load DNAcopy
library(DNAcopy)
@@ -7,7 +7,9 @@
#load(paste(packagepath,"/data/commonSnps132.RData",sep=""))
load(paste(packagepath,"/data/ideogram.RData",sep=""))
#load(paste(packagepath,"/data/normaldata.RData",sep=""))
+ load("pile.alleles.Rdata")
chroms=as.character(unique(ideogram$chr))
+ load("smoothed.Rdata")
# Segmentation
segs <- allsegs <- NULL;
Modified: pkg/patchwork/R/patchwork.segment.r
===================================================================
--- pkg/patchwork/R/patchwork.segment.r 2011-11-22 15:58:41 UTC (rev 27)
+++ pkg/patchwork/R/patchwork.segment.r 2011-11-25 12:50:34 UTC (rev 28)
@@ -1,5 +1,6 @@
-patchwork.segment <- function(kbsegs,chroms)
+patchwork.segment <- function(kbsegs,chroms,Alpha,SD)
{
+ library(DNAcopy)
#Load data included in package
packagepath = system.file(package="patchwork")
#load(paste(packagepath,"/data/commonSnps132.RData",sep=""))
@@ -14,13 +15,13 @@
ix= kbsegs$chr==c & kbsegs$pos < ideogram$start[ideogram$chr==c]
if (sum(ix)>0)
{
- psegments=segment(smooth.CNA(CNA(kbsegs$ratio[ix], c, kbsegs$pos[ix], data.type='logratio',sampleid=paste(c,'p')),smooth.region=40), undo.splits='sdundo', undo.SD=1,min.width=5, alpha=0.0001)$output[,2:6]
+ psegments=segment(smooth.CNA(CNA(kbsegs$ratio[ix], c, kbsegs$pos[ix], data.type='logratio',sampleid=paste(c,'p')),smooth.region=40), undo.splits='sdundo', undo.SD=SD,min.width=5, alpha=Alpha)$output[,2:6]
psegments$arm='p'
}
ix=kbsegs$chr==c & kbsegs$pos > ideogram$end[ideogram$chr==c]
if (sum(ix)>0)
{
- qsegments=segment(smooth.CNA(CNA(kbsegs$ratio[ix], c, kbsegs$pos[ix], data.type='logratio',sampleid=paste(c,'q')),smooth.region=40), undo.splits='sdundo', undo.SD=1,min.width=5, alpha=0.0001)$output[,2:6]
+ qsegments=segment(smooth.CNA(CNA(kbsegs$ratio[ix], c, kbsegs$pos[ix], data.type='logratio',sampleid=paste(c,'q')),smooth.region=40), undo.splits='sdundo', undo.SD=SD,min.width=5, alpha=Alpha)$output[,2:6]
qsegments$arm='q'
}
segs=rbind(segs,psegments,qsegments)
More information about the Patchwork-commits
mailing list