Bioconductor / RaggedExperiment

Matrix-like representations of mutation and CN data
https://bioconductor.org/packages/RaggedExperiment
4 stars 3 forks source link

Error in assay<- / assays<- #22

Closed lgeistlinger closed 5 years ago

lgeistlinger commented 5 years ago

Same example as https://github.com/Bioconductor/RaggedExperiment/issues/21#issue-402372474

I would now like to change the order of the assays, particularly to make the Segment_mean (= copy number estimate) the default assay, instead of Num_probes (= number of SNPs used to infer the CN).

However, these attempts fail:

  1. reorder

    > assays(gbm.ra) <- assays(gbm.ra)[2:1]
    Error in (function (classes, fdef, mtable)  : 
    unable to find an inherited method for function ‘assays<-’ for signature ‘"RaggedExperiment", "SimpleList"’
  2. overwrite

    > assays(gbm.ra, 1) <- assays(gbm.ra, 2)
    Error in (function (classes, fdef, mtable)  : 
    unable to find an inherited method for function ‘assays<-’ for signature ‘"RaggedExperiment", "SimpleList"’
  3. alternative overwrite

    > assay(gbm.ra) <- assays(gbm.ra)[[2]]
    Error in (function (classes, fdef, mtable)  : 
    unable to find an inherited method for function ‘assay<-’ for signature ‘"RaggedExperiment", "missing"’
LiNk-NY commented 5 years ago

Hi Ludwig, @lgeistlinger Calling assays instantiates the representations of the metadata columns as matrices. I would use that function sparingly.

You can use mcols or rowData for this operation.

gbm <- curatedTCGAData::curatedTCGAData("GBM", "CNVSNP", FALSE)
#> snapshotDate(): 2019-01-15
#> see ?curatedTCGAData and browseVignettes('curatedTCGAData') for documentation
#> downloading 0 resources
#> loading from cache 
#>     '/home/mr148//.ExperimentHub/670'
#> Loading required package: RaggedExperiment
#> see ?curatedTCGAData and browseVignettes('curatedTCGAData') for documentation
#> downloading 0 resources
#> loading from cache 
#>     '/home/mr148//.ExperimentHub/671'
#> see ?curatedTCGAData and browseVignettes('curatedTCGAData') for documentation
#> downloading 0 resources
#> loading from cache 
#>     '/home/mr148//.ExperimentHub/674'
#> see ?curatedTCGAData and browseVignettes('curatedTCGAData') for documentation
#> downloading 0 resources
#> loading from cache 
#>     '/home/mr148//.ExperimentHub/685'
#> harmonizing input:
#>   removing 6776 sampleMap rows not in names(experiments)
#>   removing 7 colData rownames not in sampleMap 'primary'
gbm.ra <- gbm[[1]]
mcols(gbm.ra)
#> DataFrame with 146852 rows and 2 columns
#>        Num_Probes Segment_Mean
#>         <numeric>    <numeric>
#> 1             166       0.1112
#> 2               3      -1.2062
#> 3           40303       0.1086
#> 4             271      -0.3065
#> 5           88288       0.1049
#> ...           ...          ...
#> 146848          4      -1.1898
#> 146849      14607       0.0095
#> 146850          4      -1.1041
#> 146851        399       0.0052
#> 146852      63445       0.0081
mcols(gbm.ra) <- mcols(gbm.ra)[, 2:1]
gbm.ra
#> class: RaggedExperiment 
#> dim: 146852 1104 
#> assays(2): Segment_Mean Num_Probes
#> rownames: NULL
#> colnames(1104): TCGA-02-0001-01C-01D-0182-01
#>   TCGA-02-0001-10A-01D-0182-01 ... TCGA-RR-A6KC-01A-31D-A33S-01
#>   TCGA-RR-A6KC-10A-01D-A33V-01
#> colData names(0):

Created on 2019-01-23 by the reprex package (v0.2.1)

lgeistlinger commented 5 years ago

Cool, thanks again!