Inserting "Biotype" into scater SCE objects
Entering edit mode
Last seen 3.6 years ago

Apologies is this is a very basic question, but as a newcomer I have been scouring forums and help documentation for hours and would appreciate some guidance if anybody has time.

I have a SCE object created using the constructor in scater 1.6.3 which I am using for QC but would like to explore the biotype of the features. I initially envisioned this as a simple task of cbinding the relevant data into the object.

The only way I have thus far managed to integrate the biotype data into the SCE object is by ensuring it is in the annotations file and reconstructing the object from scratch using the annotations as Rowdata in the constructor.

str(sce) excerpt below: 

@elementMetadata:Formal class 'DataFrame' [package "S4Vectors"] with 6 slots

  .. .. .. .. ..@ rownames       : NULL

  .. .. .. .. ..@ nrows          : int 27590

  .. .. .. .. ..@ listData       :List of 18

  .. .. .. .. .. ..$ GeneID                 : Factor w/ 52005 levels "EGFP

Etc etc etc

  .. .. .. .. .. ..$ biotype                : chr [1:27590] "protein_coding" 


What I think I need are the data as a column however so I can assign colour/shapes to the biotype  in visualizations etc . Thus far, I’m unable to merge or cbind the annotation file or even newly created simple dataframes derived from it or cbind the matched rows.

Error in as.vector(x) : no method for coercing this S4 class to a vector

Some stack exchange posts discussing this error more generically have discussed adding NAMESPACE to objects, but this is never specific to scater or SCE. I would appreciate any direction that could be given

Again, apologies if the question is not specific enough to the field of bioinformatics for the forum.



> sessionInfo()

R version 3.4.3 (2017-11-30)

Platform: x86_64-w64-mingw32/x64 (64-bit)

Running under: Windows >= 8 x64 (build 9200)


Matrix products: default



[1] LC_COLLATE=English_United Kingdom.1252  LC_CTYPE=English_United Kingdom.1252   

[3] LC_MONETARY=English_United Kingdom.1252 LC_NUMERIC=C                           

[5] LC_TIME=English_United Kingdom.1252    


attached base packages:

[1] stats4    parallel  stats     graphics  grDevices utils     datasets  methods   base     


other attached packages:

 [1] BiocInstaller_1.28.0       dplyr_0.7.4                magrittr_1.5               refGenome_1.7.3           

 [5] RSQLite_2.0                doBy_4.5-15                scater_1.6.3               limma_3.34.9              

 [9] SingleCellExperiment_1.0.0 SummarizedExperiment_1.8.1 DelayedArray_0.4.1         matrixStats_0.53.1        

[13] GenomicRanges_1.30.0       GenomeInfoDb_1.14.0        IRanges_2.12.0             S4Vectors_0.16.0          

[17] ggplot2_2.2.1              Biobase_2.38.0             BiocGenerics_0.24.0       


loaded via a namespace (and not attached):
scater sce biotype R • 467 views
Entering edit mode
Aaron Lun ★ 27k
Last seen 20 hours ago
The city by the bay

This should not be hard.


# making a pretend SCE object and BioType.
biotype <- sample(c("protein", "lncRNA", "junk"), nrow(sce), replace=TRUE)

# Inserting as a single column:
rowData(sce)$BioType <- biotype
## [1] "BioType"

# Or if you have a data.frame:
stuff <- data.frame(BioTypeX=biotype)
rowData(sce) <- cbind(rowData(sce), stuff)
## [1] "BioType"  "BioTypeX"

# Or you can just override the existing row data:
rowData(sce) <- stuff
## [1] "BioTypeX"

All scater constructors should eventually call SingleCellExperiment, so that shouldn't be an issue.

Entering edit mode

God, Just looking at those solutions I really had myself tied up in knots, thats fantastic thanks!


Login before adding your answer.

Traffic: 179 users visited in the last hour
Help About
Access RSS

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

Powered by the version 2.3.6