Subsetting qPCRset loses sample names, possibly due to change of assayDataElementReplace
1
1
Entering edit mode
@henrikseidel-11484
Last seen 7.9 years ago

When subsetting a qPCRset (e.g., for features), the sample names get lost. Assigning an expression set explicitly does not work as well. Let's say raw is a qPCRset:

rawSub <- raw[myFeatures, ]

sampleNames(raw) # result is correct, e.g. "Sample1", "Sample2", ...

sampleNames(rawSub) # result is just "1", "2", ...

When I try to assign an expression set explicitly, I get an error message:

es <- exprs(rawSub)

colnames(es) <- sampleNames(raw)

exprs(rawSub) <- es

Error in assayDataElementReplace(object, "exprs", value, validate = TRUE) : 
  unused argument (validate = TRUE)

In the current Bioconductor version (3.4) the function "assayDataElementReplace" indeed does not have an argument "validate". In previous versions this function had "validate" as an argument, and the default was TRUE. My guess is that now the error I mentioned above is also triggered but silently ignored when subsetting a qPCRset. I think that the HTqPCR package should be modified to remove the "validate" argument. Because "validate = TRUE" was the default in previous Bioconductor versions of assayDataElementReplace, HTqPCR would still work correctly even for those older Bioconductor versions.

Here are the source code locations which need to be changed:

qPCRset.R:32: function (object, value) assayDataElementReplace(object, "exprs", value, validate=TRUE)
qPCRset.R:157: function (object, value) assayDataElementReplace(object, "featureCategory", value, validate=FALSE)
qPCRset.R:184: function (object, value) assayDataElementReplace(object, "flag", value, validate=FALSE)

Regards

Henrik

HTqPCR • 2.3k views
ADD COMMENT
0
Entering edit mode

Just saw that you used "validate=FALSE" for "featureCategory" and "flag", so removing the "validate" argument would change something for older Bioconductor versions. Not sure if this would be an issue.

ADD REPLY
0
Entering edit mode

Okay, the patch below makes it at least possible to assign modified expression sets to a qPCRset (so I can at least fix the sample names). But subsetting a qPCRset still removed sample names. So there seems to be more which requires a fix.

ADD REPLY
0
Entering edit mode

Patch removed, see answer.

ADD REPLY
2
Entering edit mode
@henrikseidel-11484
Last seen 7.9 years ago

I think I solved both issues now.

  1. I removed the "validate" argument from the calls to assayDataElementReplace.
  2. When subsetting a qPCRset, there was a call to the function "unname" before assigning the subset of the original exprs to the new qPCRset:
    exprs=unname(exprs(x)[i, j, drop=FALSE])
    It is not clear to me why you would want to remove row and column names here. I removed this call to "unname", so the row and column names of the original exprs are retained.
diff --git a/DESCRIPTION b/DESCRIPTION
index 3736f63..b4e749d 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
 Package: HTqPCR
 Type: Package
 Title: Automated analysis of high-throughput qPCR data
-Version: 1.28.0
+Version: 1.28.2
 Author: Heidi Dvinge, Paul Bertone
 Maintainer: Heidi Dvinge <hdvinge@fredhutch.org>
 Description: Analysis of Ct values from high throughput quantitative
diff --git a/R/qPCRset.R b/R/qPCRset.R
index 1cd043a..d400ea5 100644
--- a/R/qPCRset.R
+++ b/R/qPCRset.R
@@ -29,7 +29,7 @@ setMethod("sampleNames",
 #------------------------------------------------------------------
 
 setReplaceMethod("exprs", signature(object="qPCRset"), definition =
- function (object, value) assayDataElementReplace(object, "exprs", value, validate=TRUE)
+ function (object, value) assayDataElementReplace(object, "exprs", value)
 )
 
 setReplaceMethod("featureNames",
@@ -69,7 +69,7 @@ function(x, i, j, drop=FALSE) {
     if (missing(j))
         j <- 1:ncol(x)
     out <- new("qPCRset",
-                exprs=unname(exprs(x)[i, j, drop=FALSE]),
+                exprs=exprs(x)[i, j, drop=FALSE],
                 featureCategory=featureCategory(x)[i, j, drop=FALSE],
                 flag=flag(x)[i, j, drop=FALSE])
     phenoData(out) <- phenoData(x)[j,,drop=FALSE]
@@ -154,7 +154,7 @@ setMethod("featureCategory", signature = "qPCRset", definition =
 )
 
 setReplaceMethod("featureCategory", signature = "qPCRset", definition =
- function (object, value) assayDataElementReplace(object, "featureCategory", value, validate=FALSE)
+ function (object, value) assayDataElementReplace(object, "featureCategory", value)
 )
 
 
@@ -181,7 +181,7 @@ setMethod("flag", signature = "qPCRset", definition =
 )
 
 setReplaceMethod("flag", signature = "qPCRset", definition =
- function (object, value) assayDataElementReplace(object, "flag", value, validate=FALSE)
+ function (object, value) assayDataElementReplace(object, "flag", value)
 )
 
 
diff --git a/man/HTqPCR-package.Rd b/man/HTqPCR-package.Rd
index 2d1af1e..4849186 100644
--- a/man/HTqPCR-package.Rd
+++ b/man/HTqPCR-package.Rd
@@ -12,8 +12,8 @@
 \tabular{ll}{
 Package: \tab HTqPCR\cr
 Type: \tab Package\cr
-Version: \tab 1.0\cr
-Date: \tab 2009-07-03\cr
+Version: \tab 1.28.2\cr
+Date: \tab 2017-01-25\cr
 License: \tab Artistic\cr
 LazyLoad: \tab yes\cr
 Depends: \tab methods\cr

 

ADD COMMENT
0
Entering edit mode

Hi Hendrik,

Thanks for all your work and contributions on this!

I noticed your other contribution regarding the loss of featureData. It also seems to me that the subsetting is somehow creating other problems, as a subset qPCRset object (but not the original one) will give the following error message:

> diff.exp <- limmaCtData(filt_A2, design=design, contrasts=contrasts)
Error in data.frame(..., check.names = FALSE) : arguments imply differing number of rows: 261, 0

I am a very basic R user, with minimal  programming skills and really pressed for time to re-run a simple analysis I did over a year ago on a new dataset. I haven't figured out exactly how to introduce your corrections in the package and I'm also wondering if they will solve this other issue. Any suggestions would be really most welcome! 

Meg

ADD REPLY
0
Entering edit mode

Just to confirm this issue. The same happens not only on sub setting a qPCRset but also when you try reassigning samples names. I mean, considering raw a qPCRset, such problem appears if I you rename samples:

R »sampleNames(raw) <- rownames(phenoData)

 Error in (function (od, vd)  : 
  object and replacement value dimnames differ
Calls: sampleNames<- ... .validate_assayDataElementReplace -> Map -> mapply -> <Anonymous>

 

##### SESSION INFO #####

R » sessionInfo()

R version 3.3.2 (2016-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Gentoo/Linux

locale:
 [1] LC_CTYPE=pt_BR.utf8       LC_NUMERIC=C              LC_TIME=pt_BR.utf8        LC_COLLATE=pt_BR.utf8     LC_MONETARY=pt_BR.utf8   
 [6] LC_MESSAGES=pt_BR.utf8    LC_PAPER=pt_BR.utf8       LC_NAME=C                 LC_ADDRESS=C              LC_TELEPHONE=C           
[11] LC_MEASUREMENT=pt_BR.utf8 LC_IDENTIFICATION=C      

attached base packages:
[1] parallel  stats     graphics  grDevices datasets  utils     methods   base     

other attached packages:
[1] HTqPCR_1.28.0        limma_3.30.13        RColorBrewer_1.1-2   Biobase_2.34.0       BiocGenerics_0.20.0  BiocInstaller_1.24.0 setwidth_1.0-4      
[8] colorout_1.1-0      

loaded via a namespace (and not attached):
 [1] gtools_3.5.0          bitops_1.0-6          affy_1.52.0           stats4_3.3.2          KernSmooth_2.23-15    gplots_3.0.1          zlibbioc_1.20.0      
 [8] gdata_2.18.0          affyio_1.44.0         preprocessCore_1.36.0 caTools_1.17.1       

ADD REPLY
0
Entering edit mode

Could someone, please, possibly provide more information on patching the qPCRset.R file? 

Shouldn't be such patch in Bioconductor repo?

Any help is appreciated.

 

ADD REPLY

Login before adding your answer.

Traffic: 423 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6