[Patchwork-commits] r68 - in pkg/patchworkCG: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Thu Jan 19 14:56:00 CET 2012
Author: sebastian_d
Date: 2012-01-19 14:56:00 +0100 (Thu, 19 Jan 2012)
New Revision: 68
Modified:
pkg/patchworkCG/R/CG_KaCh.r
pkg/patchworkCG/R/patchwork.CG.r
pkg/patchworkCG/R/patchwork.CGCNV.r
pkg/patchworkCG/README
pkg/patchworkCG/man/patchwork.CG.Rd
pkg/patchworkCG/man/subfunctions_CGCNV.Rd
Log:
Some modifications to get CGCNV working
Modified: pkg/patchworkCG/R/CG_KaCh.r
===================================================================
--- pkg/patchworkCG/R/CG_KaCh.r 2012-01-11 09:22:29 UTC (rev 67)
+++ pkg/patchworkCG/R/CG_KaCh.r 2012-01-19 13:56:00 UTC (rev 68)
@@ -6,7 +6,7 @@
#load(paste(packagepath,"/data/ideogram.RData",sep=""))
- data(ideogram,package="patchworkGC")
+ data(ideogram,package="patchworkCG")
#create a color ramp palette to segue the color scheme for plot.
Modified: pkg/patchworkCG/R/patchwork.CG.r
===================================================================
--- pkg/patchworkCG/R/patchwork.CG.r 2012-01-11 09:22:29 UTC (rev 67)
+++ pkg/patchworkCG/R/patchwork.CG.r 2012-01-19 13:56:00 UTC (rev 68)
@@ -1,21 +1,22 @@
-patchwork.CG <- function(path,name='CG_sample_',override_file_input = FALSE)
+patchwork.CG <- function(path,name='CG_sample_',manual_file_input = FALSE,masterVarBeta=NULL,somaticCnvSegments=NULL)
{
#------------------------------------------------#
# Read input files
#------------------------------------------------#
- if(override_file_input==TRUE)
+ #Choose one of the three modes of input.
+ if(manual_file_input==TRUE)
{
#Prompt for input of path to your files.
cat("ex: ~/user/documents/projekt/masterVarBeta-123-456-ASM-T1-N1.tsv")
- cat("\n Enter complete path AND filename to your masterVarBeta file:")
- mv = scan(n=1)
- cat("\n ex: ~/user/documents/projekt/somaticCnvSegmentsNondiploidBeta-123-456-ASM-T1-N1.tsv")
- cat("\n Enter complete path AND filename to your somaticCnvSegmentsNondiploidBeta file:")
- sm = scan(n=1)
+ cat("\n","Enter complete path AND filename to your masterVarBeta file:","\n")
+ mv = scan(n=1,what=character())
+ cat("\n","ex: ~/user/documents/projekt/somaticCnvSegmentsNondiploidBeta-123-456-ASM-T1-N1.tsv")
+ cat("\n","Enter complete path AND filename to your somaticCnvSegmentsNondiploidBeta file:","\n")
+ sm = scan(n=1,what=character())
- cat("\n Reading files from ASM folder \n")
+ cat("\n","Reading files","\n")
#Read masterVarBeta
mastervar = read.table(mv, sep="\t",skip=21,
@@ -23,20 +24,44 @@
"NULL","character",rep("NULL",16),"numeric","numeric",
rep("NULL",17),"integer","integer",rep("NULL",5)))
- #Read somaticCnvSegmentsNondiploidBeta in ASM/CNV folder
+ #Read somaticCnvSegmentsNondiploidBeta
segm = read.table(sm,sep="\t",skip=21,
- colClasses=c("character","integer","integer","numeric","numeric",
- rep("NULL",7)))
+ colClasses=c("character","integer","integer","numeric","numeric",
+ rep("NULL",7)))
+
+ #save(segm,mastervar,file="QA.Rdata")
- cat("File input complete \n")
}
+ else if(length(masterVarBeta) == 1 & length(somaticCnvSegments) == 1)
+ {
+
+ mv_ = strsplit(masterVarBeta,"/")
+ sm_ = strsplit(somaticCnvSegments,"/")
+
+ mv = grep("masterVar",mv_[[1]],value=T)
+ sm = grep("somaticCnv",sm_[[1]],value=T)
+
+ cat("\n","Reading files:",mv," and ",sm,"\n")
+ #Read mastervarbeta file in ASM folder
+ mastervar = read.table(masterVarBeta,
+ sep="\t",
+ colClasses=c("NULL","NULL","character","integer","integer",
+ "NULL","character",rep("NULL",16),"numeric","numeric",
+ rep("NULL",17),"integer","integer",rep("NULL",5)),
+ skip=21)
+ #Read somaticCnvSegmentsNondiploidBeta in ASM/CNV folder
+ segm = read.table(somaticCnvSegments,
+ sep="\t",skip=21,
+ colClasses=c("character","integer","integer","numeric","numeric",
+ rep("NULL",7)))
+ }
else
{
mastervar_ = list.files(path=path,pattern="masterVar")
path_segm = paste(path,"/CNV",sep="")
segm_ = list.files(path=path_segm,pattern="somaticCnvSegmentsNondiploid")
- cat("\n Reading files from ASM folder \n")
+ cat("\n","Reading files from ASM folder \n")
#Read mastervarbeta file in ASM folder
mastervar = read.table(paste(path,"/",mastervar_,sep=""),
@@ -51,20 +76,21 @@
sep="\t",skip=21,
colClasses=c("character","integer","integer","numeric","numeric",
rep("NULL",7)))
-
+
+ }
+
colnames(segm)=c("chr","start","end","avgnormcov","relcov")
colnames(mastervar)=c("chr","begin","end","vartype","ref_count","tot_count",
"ref_countN","tot_countN")
-
+
cat("File input complete \n")
- }
#------------------------------------------------#
# Filter out unecessary/unwanted values
#------------------------------------------------#
- #Remove all rows that have NA values in column 8.
+ #Remove all rows that have NA values in column 8.(tot_countN).
mastervar = mastervar[!is.na(mastervar[,8]),]
#Only keep when referenceallelereadcount/totalreadcount is between 0.2 and 0.8
Modified: pkg/patchworkCG/R/patchwork.CGCNV.r
===================================================================
--- pkg/patchworkCG/R/patchwork.CGCNV.r 2012-01-11 09:22:29 UTC (rev 67)
+++ pkg/patchworkCG/R/patchwork.CGCNV.r 2012-01-19 13:56:00 UTC (rev 68)
@@ -1,6 +1,6 @@
patchwork.CGCNV = function(cn2,delta,het,hom,maxCn=8,ceiling=1,name="CGCNV_")
{
-
+ # patchwork.CGCNV()
#packagepath = system.file(package="patchwork")
#load(paste(packagepath,"/data/commonSnps132.RData",sep=""))
#load(paste(packagepath,"/data/ideogram.RData",sep=""))
@@ -203,8 +203,10 @@
sampleInfo <- list('int'=int,'ai'=ai)
+ ## Reassignment of regions! This removes regions$np which is used later..
## Assign total and minor copy numbers to all segments.
regions <- segs[!is.na(segs$ratio),] ## This time, work on all segments available.
+ regions$np <- round((regions$end - regions$start)/10000)
Cn <- NULL ## Total copy number
mCn <- NULL ## Minor allele copy number
@@ -261,6 +263,8 @@
regions$Cn <- Cn
regions$mCn <- mCn
regions$fullCN <- fullCN
+
+ save(regions,file="Regions.RData")
write.csv(regions,file='Copynumbers.csv')
Modified: pkg/patchworkCG/README
===================================================================
--- pkg/patchworkCG/README 2012-01-11 09:22:29 UTC (rev 67)
+++ pkg/patchworkCG/README 2012-01-19 13:56:00 UTC (rev 68)
@@ -45,11 +45,16 @@
#Start R in your working directory. (Or use setwd() after starting R wherever you choose)
#See ?patchwork.CG
+#One way of running patchwork.CG is pointing to the ASM folder:
+
patchwork.CG(<Path to your ASM folder>,name='A name that you want to prefix your output plots')
+#You can also run it pointing directly to the files or naming the files in manual input.
+#See ?patchwork.CG on how to do this.
#This should generate several plots in your working directory.
-#See ?patchwork.CGCNV
+#See ?patchwork.CGCNV on the parameters that function takes and how to read the values you
+#need from the plots generated by patchwork.CG.
patchwork.CGCNV
Modified: pkg/patchworkCG/man/patchwork.CG.Rd
===================================================================
--- pkg/patchworkCG/man/patchwork.CG.Rd 2012-01-11 09:22:29 UTC (rev 67)
+++ pkg/patchworkCG/man/patchwork.CG.Rd 2012-01-19 13:56:00 UTC (rev 68)
@@ -8,11 +8,13 @@
}
\description{
+Reads files and performs calculations later used in the plotting function.
+
In details there is some very important information, highly recommended!
}
\usage{
-patchwork.CG(path,name='CG_sample_',override_file_input=FALSE)
+patchwork.CG(path,name='CG_sample_',manual_file_input=FALSE,masterVarBeta=NULL,somaticCnvSegments=NULL)
}
\arguments{
@@ -22,16 +24,33 @@
\item{name}{
Default is 'CG_sample_'. The name you wish associated with the plots that will be generated.
}
- \item{override_file_input}{
+ \item{manual_file_input}{
Default is FALSE. If you set it to TRUE you will be prompted to provide path and filename for
both the masterVarBeta file and somaticCnvSegmentsNondiploid file.
}
+ \item{masterVarBeta}{
+ Path to AND COMPLETE name of the masterVarBeta file, should you wish to implement it directly. Useful if you want to run
+ the program on multiple samples and wish to create a script going from file to file. This saves you
+ from having to conserve the CompleteGenomics file structure.
+ Default is NULL.
+ }
+ \item{somaticCnvSegments}{
+ Path to AND COMPLETE name of the somaticCnvSegments file, should you wish to implement it directly. Useful if you want to run
+ the program on multiple samples and wish to create a script going from file to file. This saves you
+ from having to conserve the CompleteGenomics file structure.
+ Default is NULL.
+ }
}
\details{
Before execution make sure that you have unpacked the necessary files, masterVarBeta located in your ASM/
folder and somaticCnvSegmentsNonDiploidBeta located in you ASM/CNV/ folder.
+If you wish to use this function in a script so it performs its function on multiple genome entries, remember
+to also loop over the "name" parameter or you run the risk of the plots replacing eachother. The easiest way
+to script this to run over multiple files is to use the masterVarBeta and somaticCnvSegments parameters
+as opposed to the path variable.
+
It is prudent not do run multiple instances of patchwork.CG in the same directory. This can cause issues
with the generated file, read below, and also with plot names if you have kept the default value.
Modified: pkg/patchworkCG/man/subfunctions_CGCNV.Rd
===================================================================
--- pkg/patchworkCG/man/subfunctions_CGCNV.Rd 2012-01-11 09:22:29 UTC (rev 67)
+++ pkg/patchworkCG/man/subfunctions_CGCNV.Rd 2012-01-19 13:56:00 UTC (rev 68)
@@ -13,6 +13,14 @@
\description{
A number of subfunctions used within patchwork.CGCNV().
+These functions are identical in patchwork package, so should that package be installed
+before patchworkCG or vice versa you will get a non-consequential message saying:
+
+The following object(s) are masked from 'package:patchwork':
+
+ chrom_ucsc, deChrom_ucsc, is.autosome, weightedMean, weightedMedian
+
+
}
\usage{
More information about the Patchwork-commits
mailing list