Skip to content

Instantly share code, notes, and snippets.

@kieranrcampbell
Created July 26, 2018 19:48
Show Gist options
  • Save kieranrcampbell/2896b526c6fbc3b9259fc7f8f16777b1 to your computer and use it in GitHub Desktop.
Save kieranrcampbell/2896b526c6fbc3b9259fc7f8f16777b1 to your computer and use it in GitHub Desktop.
# Some common functions for manipulating bioconductor SingleCellExperiment objects
#' Return the corresponding ensembl gene id for a symbol in a given SCE
get_ensembl_id <- function(symbol, sce) {
stopifnot(symbol %in% rowData(sce)$Symbol)
rownames(sce)[rowData(sce)$Symbol == symbol]
}
#' Prepare an SCE read using read10XUtils for SC3
prepare_for_sc3 <- function(sce) {
counts(sce) <- as.matrix(counts(sce))
logcounts(sce) <- as.matrix(logcounts(sce))
rowData(sce)$feature_symbol <- rowData(sce)$Symbol
sce
}
#' Remove calculated rowData to cbind two or more SCEs together
remove_rowdata <- function(sce) {
rowData(sce)[13:20] <- NULL
sce
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment