From 6e5eeae7c65037152ed74fe7be195ccd64973675 Mon Sep 17 00:00:00 2001 From: Joe Zhu Date: Sat, 7 Dec 2024 14:28:52 +0800 Subject: [PATCH] updateing namespace --- .Rbuildignore | 4 +++ NAMESPACE | 26 +++++++++++++++++++ NEWS.md | 3 +++ R/deploid_utils.R | 5 ++++ R/utils.R | 48 +++++++++++++++++------------------ man/computeObsWSAF.Rd | 6 ++--- man/extractCoverageFromTxt.Rd | 4 +-- man/extractCoverageFromVcf.Rd | 2 +- man/extractPLAF.Rd | 2 +- man/histWSAF.Rd | 6 ++--- man/plotAltVsRef.Rd | 6 ++--- man/plotObsExpWSAF.Rd | 4 +-- man/plotProportions.Rd | 8 +++--- man/plotWSAFvsPLAF.Rd | 10 ++++---- 14 files changed, 86 insertions(+), 48 deletions(-) create mode 100644 NEWS.md diff --git a/.Rbuildignore b/.Rbuildignore index ecd3b94..ebcb184 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,7 @@ ^DEploid-Utilities\.Rproj$ ^\.Rproj\.user$ ^LICENSE\.md$ +LICENSE +.github +\*\.o +vcf/vcfReader.o diff --git a/NAMESPACE b/NAMESPACE index 912c0aa..cb7b155 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -12,5 +12,31 @@ export(plotObsExpWSAF) export(plotProportions) export(plotWSAFvsPLAF) importFrom(Rcpp,evalCpp) +importFrom(grDevices,adjustcolor) +importFrom(grDevices,colorRampPalette) +importFrom(grDevices,dev.off) +importFrom(grDevices,heat.colors) +importFrom(grDevices,pdf) +importFrom(grDevices,png) +importFrom(grDevices,rainbow) +importFrom(graphics,abline) +importFrom(graphics,axis) +importFrom(graphics,barplot) +importFrom(graphics,hist) +importFrom(graphics,image) +importFrom(graphics,layout) +importFrom(graphics,legend) +importFrom(graphics,lines) +importFrom(graphics,par) +importFrom(graphics,points) +importFrom(graphics,rect) +importFrom(magrittr,"%>%") importFrom(scales,alpha) +importFrom(stats,cor) +importFrom(stats,cov) +importFrom(stats,quantile) +importFrom(stats,sd) +importFrom(stats,var) +importFrom(utils,read.table) +importFrom(utils,write.table) useDynLib(DEploid.utils, .registration = TRUE) diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..00c436a --- /dev/null +++ b/NEWS.md @@ -0,0 +1,3 @@ +# DEploid.utils 0.0.0.9000 + +* First release. diff --git a/R/deploid_utils.R b/R/deploid_utils.R index f8cecb1..7051b10 100644 --- a/R/deploid_utils.R +++ b/R/deploid_utils.R @@ -24,5 +24,10 @@ #' #' @importFrom Rcpp evalCpp #' @importFrom scales alpha +#' @importFrom magrittr %>% +#' @importFrom utils read.table write.table +#' @importFrom stats cor cov quantile sd var +#' @importFrom graphics abline axis barplot hist image layout legend lines par points rect +#' @importFrom grDevices adjustcolor colorRampPalette dev.off heat.colors pdf png rainbow #' @useDynLib DEploid.utils, .registration = TRUE NULL diff --git a/R/utils.R b/R/utils.R index 4fe16c8..f5e2a92 100755 --- a/R/utils.R +++ b/R/utils.R @@ -13,8 +13,8 @@ #' @export #' #' @examples -#' refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid") -#' altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid") +#' refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid.utils") +#' altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid.utils") #' PG0390 = extractCoverageFromTxt(refFile, altFile) #' extractCoverageFromTxt <- function ( refFileName, altFileName ){ @@ -43,7 +43,7 @@ extractCoverageFromTxt <- function ( refFileName, altFileName ){ #' @export #' #' @examples -#' vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid") +#' vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid.utils") #' PG0390 = extractCoverageFromVcf(vcfFile) #' extractCoverageFromVcf <- function ( vcfFileName, ADFieldIndex = 2 ){ @@ -102,7 +102,7 @@ extractCoverageFromVcf <- function ( vcfFileName, ADFieldIndex = 2 ){ #' @export #' #' @examples -#' plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid") +#' plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid.utils") #' plaf = extractPLAF(plafFile) #' extractPLAF <- function ( plafFileName ){ @@ -127,10 +127,10 @@ extractPLAF <- function ( plafFileName ){ #' @export #' #' @examples -#' plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid") -#' panelFile = system.file("extdata", "labStrains.test.panel.txt", package = "DEploid") -#' refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid") -#' altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid") +#' plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid.utils") +#' panelFile = system.file("extdata", "labStrains.test.panel.txt", package = "DEploid.utils") +#' refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid.utils") +#' altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid.utils") #' PG0390CoverageTxt = extractCoverageFromTxt(refFile, altFile) #' PG0390CoverageTxt.deconv = dEploid(paste("-ref", refFile, "-alt", altFile, #' "-plaf", plafFile, "-noPanel")) @@ -170,13 +170,13 @@ plotProportions <- function (proportions, title = "Components", #' #' @examples #' # Example 1 -#' refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid") -#' altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid") +#' refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid.utils") +#' altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid.utils") #' PG0390CoverageTxt = extractCoverageFromTxt(refFile, altFile) #' plotAltVsRef( PG0390CoverageTxt$refCount, PG0390CoverageTxt$altCount ) #' #' # Example 2 -#' vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid") +#' vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid.utils") #' PG0390CoverageVcf = extractCoverageFromVcf(vcfFile) #' plotAltVsRef( PG0390CoverageVcf$refCount, PG0390CoverageVcf$altCount ) #' @@ -230,15 +230,15 @@ plotAltVsRef <- function ( ref, alt, title = "Alt vs Ref", #' #' @examples #' # Example 1 -#' refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid") -#' altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid") +#' refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid.utils") +#' altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid.utils") #' PG0390CoverageTxt = extractCoverageFromTxt(refFile, altFile) #' obsWSAF = computeObsWSAF( PG0390CoverageTxt$altCount, PG0390CoverageTxt$refCount ) #' histWSAF(obsWSAF) #' myhist = histWSAF(obsWSAF, FALSE) #' #' # Example 2 -#' vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid") +#' vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid.utils") #' PG0390CoverageVcf = extractCoverageFromVcf(vcfFile) #' obsWSAF = computeObsWSAF( PG0390CoverageVcf$altCount, PG0390CoverageVcf$refCount ) #' histWSAF(obsWSAF) @@ -280,19 +280,19 @@ histWSAF <- function ( obsWSAF, exclusive = TRUE, #' #' @examples #' # Example 1 -#' refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid") -#' altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid") +#' refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid.utils") +#' altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid.utils") #' PG0390CoverageTxt = extractCoverageFromTxt(refFile, altFile) #' obsWSAF = computeObsWSAF( PG0390CoverageTxt$altCount, PG0390CoverageTxt$refCount ) -#' plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid") +#' plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid.utils") #' plaf = extractPLAF(plafFile) #' plotWSAFvsPLAF(plaf, obsWSAF) #' #' # Example 2 -#' vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid") +#' vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid.utils") #' PG0390CoverageVcf = extractCoverageFromVcf(vcfFile) #' obsWSAF = computeObsWSAF( PG0390CoverageVcf$altCount, PG0390CoverageVcf$refCount ) -#' plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid") +#' plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid.utils") #' plaf = extractPLAF(plafFile) #' plotWSAFvsPLAF(plaf, obsWSAF) #' @@ -331,10 +331,10 @@ plotWSAFvsPLAF <- function ( plaf, obsWSAF, expWSAF = c(), potentialOutliers = c #' @export #' #' @examples -#' vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid") +#' vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid.utils") #' PG0390CoverageVcf = extractCoverageFromVcf(vcfFile) #' obsWSAF = computeObsWSAF( PG0390CoverageVcf$altCount, PG0390CoverageVcf$refCount ) -#' plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid") +#' plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid.utils") #' PG0390CoverageVcf.deconv = dEploid(paste("-vcf", vcfFile, "-plaf", plafFile, "-noPanel")) #' prop = PG0390CoverageVcf.deconv$Proportions[dim(PG0390CoverageVcf.deconv$Proportions)[1],] #' expWSAF = t(PG0390CoverageVcf.deconv$Haps) %*% prop @@ -367,13 +367,13 @@ plotObsExpWSAF <- function (obsWSAF, expWSAF, #' #' @examples #' # Example 1 -#' refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid") -#' altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid") +#' refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid.utils") +#' altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid.utils") #' PG0390CoverageTxt = extractCoverageFromTxt(refFile, altFile) #' obsWSAF = computeObsWSAF( PG0390CoverageTxt$altCount, PG0390CoverageTxt$refCount ) #' #' # Example 2 -#' vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid") +#' vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid.utils") #' PG0390CoverageVcf = extractCoverageFromVcf(vcfFile) #' obsWSAF = computeObsWSAF( PG0390CoverageVcf$altCount, PG0390CoverageVcf$refCount ) #' diff --git a/man/computeObsWSAF.Rd b/man/computeObsWSAF.Rd index e675e81..651f1a8 100644 --- a/man/computeObsWSAF.Rd +++ b/man/computeObsWSAF.Rd @@ -19,13 +19,13 @@ Compute observed allele frequency within sample from the allele counts. } \examples{ # Example 1 -refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid") -altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid") +refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid.utils") +altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid.utils") PG0390CoverageTxt = extractCoverageFromTxt(refFile, altFile) obsWSAF = computeObsWSAF( PG0390CoverageTxt$altCount, PG0390CoverageTxt$refCount ) # Example 2 -vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid") +vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid.utils") PG0390CoverageVcf = extractCoverageFromVcf(vcfFile) obsWSAF = computeObsWSAF( PG0390CoverageVcf$altCount, PG0390CoverageVcf$refCount ) diff --git a/man/extractCoverageFromTxt.Rd b/man/extractCoverageFromTxt.Rd index 5ce6d96..556becb 100644 --- a/man/extractCoverageFromTxt.Rd +++ b/man/extractCoverageFromTxt.Rd @@ -21,8 +21,8 @@ Extract read counts from tab-delimited text files of a single sample. The allele count files must be tab-delimited. The allele count files contain three columns: chromosomes, positions and allele count. } \examples{ -refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid") -altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid") +refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid.utils") +altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid.utils") PG0390 = extractCoverageFromTxt(refFile, altFile) } diff --git a/man/extractCoverageFromVcf.Rd b/man/extractCoverageFromVcf.Rd index 13ada15..33a7dbf 100644 --- a/man/extractCoverageFromVcf.Rd +++ b/man/extractCoverageFromVcf.Rd @@ -21,7 +21,7 @@ Extract read counts from VCF file of a single sample. The VCF file should only contain one sample. If more samples present in the VCF, it only returns coverage for of the first sample. } \examples{ -vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid") +vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid.utils") PG0390 = extractCoverageFromVcf(vcfFile) } diff --git a/man/extractPLAF.Rd b/man/extractPLAF.Rd index f57aa3e..9460094 100644 --- a/man/extractPLAF.Rd +++ b/man/extractPLAF.Rd @@ -19,7 +19,7 @@ Extract population level allele frequency (PLAF) from text file. The text file must have header, and population level allele frequency recorded in the "PLAF" field. } \examples{ -plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid") +plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid.utils") plaf = extractPLAF(plafFile) } diff --git a/man/histWSAF.Rd b/man/histWSAF.Rd index e7c9900..f18a670 100644 --- a/man/histWSAF.Rd +++ b/man/histWSAF.Rd @@ -34,15 +34,15 @@ Produce histogram of the allele frequency within sample. } \examples{ # Example 1 -refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid") -altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid") +refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid.utils") +altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid.utils") PG0390CoverageTxt = extractCoverageFromTxt(refFile, altFile) obsWSAF = computeObsWSAF( PG0390CoverageTxt$altCount, PG0390CoverageTxt$refCount ) histWSAF(obsWSAF) myhist = histWSAF(obsWSAF, FALSE) # Example 2 -vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid") +vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid.utils") PG0390CoverageVcf = extractCoverageFromVcf(vcfFile) obsWSAF = computeObsWSAF( PG0390CoverageVcf$altCount, PG0390CoverageVcf$refCount ) histWSAF(obsWSAF) diff --git a/man/plotAltVsRef.Rd b/man/plotAltVsRef.Rd index e112f54..602eeb4 100644 --- a/man/plotAltVsRef.Rd +++ b/man/plotAltVsRef.Rd @@ -38,13 +38,13 @@ Plot alternative allele count vs reference allele count at each site. } \examples{ # Example 1 -refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid") -altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid") +refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid.utils") +altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid.utils") PG0390CoverageTxt = extractCoverageFromTxt(refFile, altFile) plotAltVsRef( PG0390CoverageTxt$refCount, PG0390CoverageTxt$altCount ) # Example 2 -vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid") +vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid.utils") PG0390CoverageVcf = extractCoverageFromVcf(vcfFile) plotAltVsRef( PG0390CoverageVcf$refCount, PG0390CoverageVcf$altCount ) diff --git a/man/plotObsExpWSAF.Rd b/man/plotObsExpWSAF.Rd index b36fd74..6280f98 100644 --- a/man/plotObsExpWSAF.Rd +++ b/man/plotObsExpWSAF.Rd @@ -30,10 +30,10 @@ plotObsExpWSAF( Plot observed alternative allele frequency within sample against expected WSAF. } \examples{ -vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid") +vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid.utils") PG0390CoverageVcf = extractCoverageFromVcf(vcfFile) obsWSAF = computeObsWSAF( PG0390CoverageVcf$altCount, PG0390CoverageVcf$refCount ) -plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid") +plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid.utils") PG0390CoverageVcf.deconv = dEploid(paste("-vcf", vcfFile, "-plaf", plafFile, "-noPanel")) prop = PG0390CoverageVcf.deconv$Proportions[dim(PG0390CoverageVcf.deconv$Proportions)[1],] expWSAF = t(PG0390CoverageVcf.deconv$Haps) \%*\% prop diff --git a/man/plotProportions.Rd b/man/plotProportions.Rd index 1498993..cac9c0d 100644 --- a/man/plotProportions.Rd +++ b/man/plotProportions.Rd @@ -27,10 +27,10 @@ plotProportions( Plot the MCMC samples of the proportion, indexed by the MCMC chain. } \examples{ -plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid") -panelFile = system.file("extdata", "labStrains.test.panel.txt", package = "DEploid") -refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid") -altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid") +plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid.utils") +panelFile = system.file("extdata", "labStrains.test.panel.txt", package = "DEploid.utils") +refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid.utils") +altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid.utils") PG0390CoverageTxt = extractCoverageFromTxt(refFile, altFile) PG0390CoverageTxt.deconv = dEploid(paste("-ref", refFile, "-alt", altFile, "-plaf", plafFile, "-noPanel")) diff --git a/man/plotWSAFvsPLAF.Rd b/man/plotWSAFvsPLAF.Rd index 784e550..9ab3f62 100644 --- a/man/plotWSAFvsPLAF.Rd +++ b/man/plotWSAFvsPLAF.Rd @@ -35,19 +35,19 @@ Plot allele frequencies within sample against population level. } \examples{ # Example 1 -refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid") -altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid") +refFile = system.file("extdata", "PG0390-C.test.ref", package = "DEploid.utils") +altFile = system.file("extdata", "PG0390-C.test.alt", package = "DEploid.utils") PG0390CoverageTxt = extractCoverageFromTxt(refFile, altFile) obsWSAF = computeObsWSAF( PG0390CoverageTxt$altCount, PG0390CoverageTxt$refCount ) -plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid") +plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid.utils") plaf = extractPLAF(plafFile) plotWSAFvsPLAF(plaf, obsWSAF) # Example 2 -vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid") +vcfFile = system.file("extdata", "PG0390-C.test.vcf.gz", package = "DEploid.utils") PG0390CoverageVcf = extractCoverageFromVcf(vcfFile) obsWSAF = computeObsWSAF( PG0390CoverageVcf$altCount, PG0390CoverageVcf$refCount ) -plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid") +plafFile = system.file("extdata", "labStrains.test.PLAF.txt", package = "DEploid.utils") plaf = extractPLAF(plafFile) plotWSAFvsPLAF(plaf, obsWSAF)