[Patchwork-commits] r87 - pkg/patchwork/R
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Feb 13 11:26:45 CET 2012
Author: mayrhofer
Date: 2012-02-13 11:26:44 +0100 (Mon, 13 Feb 2012)
New Revision: 87
Modified:
pkg/patchwork/R/patchwork.CNA.r
pkg/patchwork/R/patchwork.applyref.r
Log:
debugs
Modified: pkg/patchwork/R/patchwork.CNA.r
===================================================================
--- pkg/patchwork/R/patchwork.CNA.r 2012-02-09 15:39:20 UTC (rev 86)
+++ pkg/patchwork/R/patchwork.CNA.r 2012-02-13 10:26:44 UTC (rev 87)
@@ -1,4 +1,4 @@
-patchwork.CNA <- function(BamFile,Pileup,reference,normal.bam=NULL,normal.pileup=NULL,Alpha=0.0001,SD=1)
+patchwork.CNA <- function(BamFile,Pileup,reference='illumina',normal.bam=NULL,normal.pileup=NULL,Alpha=0.0001,SD=1)
{
#library(patchwork)
#patchwork.CNA("cancer.bam","pile.up",reference="illumina")
@@ -64,6 +64,22 @@
try ( load('normaldata.Rdata'), silent=TRUE )
if(is.null(normaldata))
{
+ filename=strsplit(normal.bam,'/')[[1]]; filename=filename[length(filename)]
+ path=strsplit(normal.bam,paste('/',filename,sep=''))[[1]][1]
+ olddir=getwd(); setwd(path); path=getwd(); setwd(olddir)
+ if (path != getwd()) {
+ temp=data; data=NULL
+ try( load(paste(path,'data.Rdata',sep='/')), silent=T )
+ if (is.null(data)) {
+ data=temp
+ } else {
+ normaldata=data
+ data=temp
+ }
+ }
+ }
+ if(is.null(normaldata))
+ {
cat("Initiating Read Chroms (matched normal) \n")
normaldata = patchwork.readChroms(BamFile,chroms)
cat("Read Chroms Complete (matched normal) \n")
@@ -85,7 +101,9 @@
if(length(data) < 9)
{
cat("Initiating Application of Reference \n")
- if (!is.null(normal.bam)) data <- patchwork.applyref(data,reference=reference) else data <- patchwork.applyref(data,normaldata=normaldata)
+ if (is.null(normal.bam)) {
+ data <- patchwork.applyref(data,reference=reference)
+ } else data <- patchwork.applyref(data,normaldata=normaldata)
cat("Application of Reference Complete \n")
save(data,file='data.Rdata')
}
Modified: pkg/patchwork/R/patchwork.applyref.r
===================================================================
--- pkg/patchwork/R/patchwork.applyref.r 2012-02-09 15:39:20 UTC (rev 86)
+++ pkg/patchwork/R/patchwork.applyref.r 2012-02-13 10:26:44 UTC (rev 87)
@@ -2,7 +2,12 @@
{
if (!is.null(reference)) load(reference)
-
+
+ if (!is.null(normaldata)) {
+ normaldata=normaldata[,c(1,2,7)]
+ colnames(normaldata)[3]='norm_mean'
+ }
+
data <- merge(data[,1:7],normaldata,all=F,by=1:2)
#data$ratio <- data$norm / data$norm_mean
data$reference <- data$norm_mean ## thats temporary
More information about the Patchwork-commits
mailing list