From cbd9053e068b95280d89263be5d46b3b5e96a4c4 Mon Sep 17 00:00:00 2001 From: Nicolas Broguiere Date: Thu, 7 Dec 2023 18:32:00 +0100 Subject: [PATCH] Update to seurat v5 nomenclature with layers replacing slots. Breaks compatibility with Seurat v4. --- R/AnnotateWithVEP.R | 2 +- R/AnnotatedVariableFeaturePlot.R | 2 +- R/CellSimilarityToGenotypes.R | 8 ++++---- R/Classify.R | 8 ++++---- R/ClassifyManual.R | 8 ++++---- R/ComputeMitoContent.R | 4 ++-- R/CreateGenotypeObject.R | 4 ++-- R/CrossImpute.R | 10 +++++----- R/Export10X.R | 8 ++++---- R/FindDifferentVariants.R | 12 ++++++------ R/GatherFeatures.R | 20 ++++++++++---------- R/IdentPlotQC.R | 10 +++++----- R/Impute.R | 14 +++++++------- R/NormalizeHTO.R | 4 ++-- R/PseudoBulkGenotypes.R | 8 ++++---- R/RunMDS.R | 8 ++++---- R/ScoreSignature.R | 28 ++++++++++++++-------------- R/SignaturePlotQC.R | 8 ++++---- man/CellSimilarityToGenotypes.Rd | 4 ++-- man/Classify.Rd | 6 +++--- man/ClassifyManual.Rd | 6 +++--- man/CrossImpute.Rd | 6 +++--- man/Export10X.Rd | 6 +++--- man/FindDifferentVariants.Rd | 4 ++-- man/GatherFeatures.Rd | 4 ++-- man/IdentPlotQC.Rd | 8 ++++---- man/Impute.Rd | 12 ++++++------ man/NormalizeHTO.Rd | 2 +- man/PseudoBulkGenotypes.Rd | 4 ++-- man/RunMDS.Rd | 6 +++--- man/ScoreSignature.Rd | 8 ++++---- man/ScoreSignatures.Rd | 8 ++++---- man/SignaturePlotQC.Rd | 6 +++--- 33 files changed, 128 insertions(+), 128 deletions(-) diff --git a/R/AnnotateWithVEP.R b/R/AnnotateWithVEP.R index 91a5632..a2ecc63 100644 --- a/R/AnnotateWithVEP.R +++ b/R/AnnotateWithVEP.R @@ -18,7 +18,7 @@ #' MyGenotype <- AnnotateWithVEP(MyGenotype,MyVepDataFrame,min.impact="HIGH",avoid_underscores=TRUE) #' @export -AnnotateWithVEP <- function(genotype,vep,min_impact="MODERATE",avoid_underscores=TRUE){ +AnnotateWithVEP <- function(genotype, vep, min_impact="MODERATE", avoid_underscores=TRUE){ vep2 <- vep[vep$Uploaded_variation %in% genotype@metadata$VEP_ID,c("Uploaded_variation","Location","Allele","Gene","SYMBOL","IMPACT","Consequence","Protein_position","Amino_acids","CLIN_SIG")] annotations <- data.frame(VEP_ID=genotype@metadata$VEP_ID, symbol="-",gene_ensembl_id="-",impact="-",protein_position="-",aminoacids="-", consequence="-", clinicalsign="-",summary="-",short_description="-", row.names=genotype@metadata$UNIQUE_ID) annotations$impact <- factor(annotations$impact,levels=c("-","MODIFIER","LOW","MODERATE","HIGH"),ordered = T) diff --git a/R/AnnotatedVariableFeaturePlot.R b/R/AnnotatedVariableFeaturePlot.R index b9c642c..6fdfbb0 100644 --- a/R/AnnotatedVariableFeaturePlot.R +++ b/R/AnnotatedVariableFeaturePlot.R @@ -24,7 +24,7 @@ # # Annotate only a subset of the most variable genes: #' AnnotatedVariableFeaturePlot(SeuratObject,500) -AnnotatedVariableFeaturePlot <- function(object, which.labels=NA, pt.size=1, text.size=2.5, log=NULL, xnudge=0, ynudge=0, colors=c("Black","Cyan"),selection.method=NULL, assay=NULL){ +AnnotatedVariableFeaturePlot <- function(object, which.labels=NA, pt.size=1, text.size=2.5, log=NULL, xnudge=0, ynudge=0, colors=c("Black","Cyan"), selection.method=NULL, assay=NULL){ if(sum(is.na(which.labels))){ points <- VariableFeatures(object,assay = assay) }else if(is.vector(which.labels,mode="numeric")){ diff --git a/R/CellSimilarityToGenotypes.R b/R/CellSimilarityToGenotypes.R index 6da5aa3..9e54119 100644 --- a/R/CellSimilarityToGenotypes.R +++ b/R/CellSimilarityToGenotypes.R @@ -10,7 +10,7 @@ #' @param prefix character(1). A prefix appended to the genotype names to generate the feature names in the similarity assay (Default: "Similarity-"). #' @param features.use character(n). The features (i.e. variants) to be used for the similarity calculations. Can be a vector of variants by name, or NA to use informative variants if available, or "all" (Default: "all"). #' @param assays character(3). The name of the assays within the Seurat object that contain the variant calls (sparse matrix with values 1,2,3 in vartrix conventions), and counts of reference and alt alleles (Default: c("VAR","REF","ALT")). -#' @param slots. The slots to use within the assays above (Default: c("data","data","data")). +#' @param layers The layers to use within the assays above (Default: c("data","data","data")). #' @return Returns the Seurat object #' @keywords compute cell similarity genotype fraction matching variants #' @examples @@ -18,7 +18,7 @@ #' DefaultAssay(MySeuratObject) <- "similarity" #' FeaturePlot(MySeuratObject,"Similarity-MyGenotypeName1") #' @export -CellSimilarityToGenotypes <- function(seurat, genotype, assay.name="similarity", prefix="Similarity-", features.use="all", assays=c("VAR","REF","ALT"), slots=c("data","data","data")){ +CellSimilarityToGenotypes <- function(seurat, genotype, assay.name="similarity", prefix="Similarity-", features.use="all", assays=c("VAR","REF","ALT"), layers=c("data","data","data")){ # Choose the features on which the similarity is computed (default: informative variants. If not present, all variants) if(is.na(features.use[1])){ if(length(VariableFeatures(seurat[[assays[1]]]))){ @@ -43,8 +43,8 @@ CellSimilarityToGenotypes <- function(seurat, genotype, assay.name="similarity", features.use <- intersect(features.use,rownames(seurat[[assays[1]]])) cat("Number of variants remaining:",length(features.use),"\n") } - tmp0 <- Matrix::t(GetAssayData(seurat, assay = assays[1], slot = slots[1])[features.use,]) - cvg0 <- Matrix::t(GetAssayData(seurat, assay = assays[2], slot = slots[2])[features.use,]+GetAssayData(seurat, assay = assays[3], slot = slots[3])[features.use,]) + tmp0 <- Matrix::t(GetAssayData(seurat, assay = assays[1], layer = layers[1])[features.use,]) + cvg0 <- Matrix::t(GetAssayData(seurat, assay = assays[2], layer = layers[2])[features.use,] + GetAssayData(seurat, assay = assays[3], layer = layers[3])[features.use,]) tmp1 <- Matrix::t(genotype[features.use,]) # # Previous simple version - perfect match only: diff --git a/R/Classify.R b/R/Classify.R index fbdfe60..4d922cb 100644 --- a/R/Classify.R +++ b/R/Classify.R @@ -12,7 +12,7 @@ #' @param metadata.name character(1). The name of the new metadata column where cell type annotations are stored (Default: celltype) #' @param cell.names character(n). Give only if the signature names should not be used as celltypes names, but rather be replaced by these cell names. #' @param assay character(1). If some signatures used for classification are stored as assay features, which assay should be used in priority (Default: DefaultAssay(object)). -#' @param slot character(1). If some signatures used for classification are stored as assay features, which slot should be used (Default: "data"). +#' @param layer character(1). If some signatures used for classification are stored as assay features, which layer should be used (Default: "data"). #' @param restrict.ident character(1). The name of a metadata column containing celltype annotations, which will be used to define the subset of cells that should be classified. Default: "Default", which uses current default, i.e. Idents(object). #' @param restrict.to character(n). Which celltypes (as defined in the restrict.ident metadata column) should be classified. Default: All cells. #' @param by.clusters character(1) or character(n) or factor(n). If not NULL, clusters instead of single cells will be classified. The parameter should indicate the name of a metadata column containing the clusters to consider (e.g. "seurat_clusters"), or the actual cluster info (e.g. object$seurat_clusters). @@ -20,13 +20,13 @@ #' @keywords Cell type classification celltype Classifier #' @export #' @examples -#' # After MySeuratObject has been log-normalized in order to contain an RNA>data assay>slot and been augmented with a percent.mito metadata column: +#' # After MySeuratObject has been log-normalized in order to contain an RNA>data assay>layer and been augmented with a percent.mito metadata column: #' # SignatureList should be a list of character vectors, each containing a series of feature/gene names. In this example, the signatures correspond to cell types, and the name of each signature is the name of the corresponding cell type (e.g. Tcell, Bcell, EpithelialCell, Fibroblasts, etc). #' MySeuratObject <- Impute(MySeuratObject) #' MySeuratObject <- ScoreSignatures(MySeuratObject,SignatureList) #' MySeuratObject <- Classify(MySeuratObject,SignatureList) # Automatic annotation based on cell type signatures, stored in metadata column "celltype". -Classify <- function(object, signatures, expected.values=NA, metadata.name="celltype", cell.names=NA, assay=DefaultAssay(object), slot="data", restrict.ident="Default", restrict.to=as.character(unique(Idents(object))), by.clusters=NULL){ +Classify <- function(object, signatures, expected.values=NA, metadata.name="celltype", cell.names=NA, assay=DefaultAssay(object), layer="data", restrict.ident="Default", restrict.to=as.character(unique(Idents(object))), by.clusters=NULL){ # Check that the idents requested for restriction are correct if(length(restrict.ident) != 1){ @@ -86,7 +86,7 @@ Classify <- function(object, signatures, expected.values=NA, metadata.name="cell } # Create a df with the signatures and features to be used: - df <- GatherFeatures(object, sign.names, assay=assay, slot=slot) + df <- GatherFeatures(object, sign.names, assay=assay, layer=layer) df <- df[cells.use,,drop=F] if(!ncol(df)){ warning("None of the requested features/signatures were found. Did you forget to run Impute and/or ScoreSignatures?") diff --git a/R/ClassifyManual.R b/R/ClassifyManual.R index df797b8..52c4abc 100644 --- a/R/ClassifyManual.R +++ b/R/ClassifyManual.R @@ -17,7 +17,7 @@ #' @param gates charater(1). Gate definitions, with gates for various cell types delimited by commas (,). For each gate, the name of the cell type is given first, followed by equal (=) and a series of gates separated by AND symbol (&). Example: "celltype_a = sign_a > value_aa & sign_b < value_ab, celltype_b = sign_b > value_ba & sign_a < value_ab" where sign_a and sign_b are the names of metadata columns and value_xy are numeric values. #' @param metadata.name The name of the new metadata column where cell type annotations are stored (Default: celltype) #' @param assay character(1). If some signatures used for classification are stored as assay features, which assay should be used in priority (Default: DefaultAssay(object)). -#' @param slot character(1). If some signatures used for classification are stored as assay features, which slot should be used (Default: "data"). +#' @param layer character(1). If some signatures used for classification are stored as assay features, which layer should be used (Default: "data"). #' @param restrict.ident character(1). The name of a metadata column containing celltype annotations, which will be used to define the subset of cells that should be classified. Default: current Idents(object). #' @param restrict.to character(n). Which celltypes (as defined in the restrict.ident metadata column) should be classified. Default: All cells. #' @param unclassified.name character(1). Which name should be given to the cells which do not pass any gate. Can be set to "keep" to keep the existing names for cells which don't pass any gate. Default: "None". @@ -26,7 +26,7 @@ #' @keywords Cell type classification celltype Classifier manual gates gating #' @export #' @examples -#' # MySeuratObject should contain an RNA slot with log-normalized data assay. +#' # MySeuratObject should contain an RNA layer with log-normalized data assay. #' # In this example cells are classified as T cells (TC) or Epithelial cells (EP) based on manual signatures. #' # Note that cells that validate no gate will have cell type "None", and cells which validate several will be classified as "Multiplets". #' # It's recommended to first do a signature scatter plot in order to choose threshold values for the gates. @@ -44,7 +44,7 @@ #' # Mark dividing cells by adding a suffix to their cell names: #' MySeuratObject <- ClassifyManual(MySeuratObject, gates="Dividing = PCNA > 1 & MKI67 > 1", naming.mode = "suffix", unclassified.name="") -ClassifyManual <- function(object, gates, metadata.name="celltype", assay=DefaultAssay(object), slot="data", restrict.ident="Default", restrict.to=as.character(unique(Idents(object))), unclassified.name="None", naming.mode="replace"){ +ClassifyManual <- function(object, gates, metadata.name="celltype", assay=DefaultAssay(object), layer="data", restrict.ident="Default", restrict.to=as.character(unique(Idents(object))), unclassified.name="None", naming.mode="replace"){ # Check that the requested Idents to use are correct if(!length(restrict.ident)){ @@ -95,7 +95,7 @@ ClassifyManual <- function(object, gates, metadata.name="celltype", assay=Defaul # Create a df with the signatures and features to be used: unique.signatures.needed <- unique(unlist(lapply(strsplit(unlist(subgates),"<|>"),"[",1))) - df <- GatherFeatures(object, unique.signatures.needed, assay=assay, slot=slot) + df <- GatherFeatures(object, unique.signatures.needed, assay=assay, layer=layer) df <- df[cells.use,,drop=F] if(!ncol(df)){ warning("None of the requested features/signatures were found. Did you forget to run Impute and/or ScoreSignatures?") diff --git a/R/ComputeMitoContent.R b/R/ComputeMitoContent.R index 29c3e66..bb67268 100644 --- a/R/ComputeMitoContent.R +++ b/R/ComputeMitoContent.R @@ -21,9 +21,9 @@ ComputeMitoContent <- function(object, name = "percent.mito", as.percent = TRUE) return(object) }else{ if(n_hu>n_mm){ - mito.content <- Matrix::colSums(GetAssayData(object[human_mito_genes, ],"counts",assay="RNA"))/Matrix::colSums(GetAssayData(object,"counts",assay="RNA")) + mito.content <- Matrix::colSums(GetAssayData(object[human_mito_genes, ],"counts", layer="RNA"))/Matrix::colSums(GetAssayData(object,"counts", layer="RNA")) }else{ - mito.content <- Matrix::colSums(GetAssayData(object[mouse_mito_genes, ],"counts",assay="RNA"))/Matrix::colSums(GetAssayData(object,"counts",assay="RNA")) + mito.content <- Matrix::colSums(GetAssayData(object[mouse_mito_genes, ],"counts", layer="RNA"))/Matrix::colSums(GetAssayData(object,"counts", layer="RNA")) } if(as.percent){ mito.content <- 100*mito.content diff --git a/R/CreateGenotypeObject.R b/R/CreateGenotypeObject.R index fa48bff..4485340 100644 --- a/R/CreateGenotypeObject.R +++ b/R/CreateGenotypeObject.R @@ -28,7 +28,7 @@ #' @export CreateGenotypeObject <- function(matrix=NULL, metadata=NULL, vartrix=list(), variants=NULL, ...){ if(is.null(variants)){ - if(!dplyr::setequal(rownames(matrix),rownames(metadata))){ + if(!dplyr::setequal(rownames(matrix), rownames(metadata))){ warning("The row names in the matrix and metadata do not match, and list of variants is not given. Aborting.") }else{ variants <- rownames(matrix) @@ -37,5 +37,5 @@ CreateGenotypeObject <- function(matrix=NULL, metadata=NULL, vartrix=list(), var if(!is.null(matrix)) rownames(matrix) <- variants if(!is.null(metadata)) rownames(metadata) <- variants if(length(vartrix)) rownames(vartrix) <- variants - return(GenotypeObject(matrix=matrix,metadata=metadata,vartrix=vartrix,variants=variants)) + return(GenotypeObject(matrix=matrix, metadata=metadata, vartrix=vartrix, variants=variants)) } diff --git a/R/CrossImpute.R b/R/CrossImpute.R index 8de4cca..2944d47 100644 --- a/R/CrossImpute.R +++ b/R/CrossImpute.R @@ -12,14 +12,14 @@ #' @param knn integer(1). Number of nearest neighbors on which to compute bandiwth imputation. #' @param t integer(1). Diffusion parameter passed to MAGIC. #' @param n.jobs integer(1). Number of threads on which to run the imputation (Default: 6). -#' @param slot.use character(1). Name of the slot to impute (Default: "data"). -#' @return Seurat object with an additional slot containing MAGIC cross-imputed data. +#' @param layer.use character(1). Name of the layer to impute (Default: "data"). +#' @return Seurat object with an additional layer containing MAGIC cross-imputed data. #' @keywords MAGIC Rmagic imputation crossimputation cross-imputation #' @export #' @examples #' MySeuratObject <- CrossImpute(MySeuratObject,"other_assay_to_impute_based_on_RNA_distances") #' MySeuratObject[["imputed-RNA"]] # Check result -CrossImpute <- function(object, impute.assay=DefaultAssay(object), name=paste0("imputed.",impute.assay), impute.features="all", reference.assay="RNA", reference.features="variable_features", npca=40, knn=3, t=2, n.jobs=6, slot.use="data"){ +CrossImpute <- function(object, impute.assay=DefaultAssay(object), name=paste0("imputed.",impute.assay), impute.features="all", reference.assay="RNA", reference.features="variable_features", npca=40, knn=3, t=2, n.jobs=6, layer.use="data"){ if(!"Rmagic" %in% rownames(installed.packages())){ stop('Rmagic is not installed, but needed for imputations. Consider running: devtools::install_github("cran/Rmagic"). The python version magic-impute is also needed, see install instructions at https://github.com/cran/Rmagic.') @@ -63,7 +63,7 @@ CrossImpute <- function(object, impute.assay=DefaultAssay(object), name=paste0(" warning("No features to impute available, aborting.") return(object) }else{ - df <- t(as.matrix(GetAssayData(object = object, slot = slot.use)[impute.features,,drop=F])) + df <- t(as.matrix(GetAssayData(object = object, layer = layer.use)[impute.features,,drop=F])) } } @@ -83,7 +83,7 @@ CrossImpute <- function(object, impute.assay=DefaultAssay(object), name=paste0(" warning("No reference features available, aborting.") return(object) }else{ - df <- cbind(df,t(as.matrix(GetAssayData(object = object, slot = slot.use)[reference.features,,drop=F]))) + df <- cbind(df,t(as.matrix(GetAssayData(object = object, layer = layer.use)[reference.features,,drop=F]))) } imputed <- Rmagic::magic(data = as.matrix(df), npca=npca, knn=knn, t=t, n.jobs=n.jobs) diff --git a/R/Export10X.R b/R/Export10X.R index 9ad1c93..b259108 100644 --- a/R/Export10X.R +++ b/R/Export10X.R @@ -11,7 +11,7 @@ #' @param cols character(1). Name of the exported file that lists column names. Default: barcodes.tsv #' @param counts character(1). Name of the exported file that contains the sparse raw count matrix. Default: matrix.mtx #' @param meta character(1). Name of the exported file that contains the metadata. Default: metadata.tsv -#' @param slot character(1). Name of the slot in the Seurat object from which the count matrix is exported. Default: counts +#' @param layer character(1). Name of the layer in the Seurat object from which the count matrix is exported. Default: counts #' @param assay character(1). Name of the assay in the Seurat object from which the count matrix is exported. Default: RNA #' @keywords Reexport export 10X #' @export @@ -21,12 +21,12 @@ #' # Include only two custom metadata columns, two dimensionality reductions, and do not compress the matrices. #' Export10X(SeuratObject, "MyDir", c("nFeature_RNA", "mito.content"), c("pca","umap"), gzip=FALSE) #' # Export normalized CiteSeq data rather than raw RNA counts, and no metadata: -#' Export10X(SeuratObject, "MyDir", meta_columns = c(), slot="data", assay="CiteSeq") -Export10X <- function(object, dir, meta_columns = "all", append_reductions = "all", gzip=T, rows = "features.tsv", cols = "barcodes.tsv", counts = "matrix.mtx", meta = "metadata.tsv", slot="counts", assay="RNA"){ +#' Export10X(SeuratObject, "MyDir", meta_columns = c(), layer="data", assay="CiteSeq") +Export10X <- function(object, dir, meta_columns = "all", append_reductions = "all", gzip=T, rows = "features.tsv", cols = "barcodes.tsv", counts = "matrix.mtx", meta = "metadata.tsv", layer="counts", assay="RNA"){ dir.backup <- getwd() if(!dir.exists(dir)){dir.create(dir)} setwd(dir) - data.tmp <- GetAssayData(object = object, slot = slot, assay = assay) + data.tmp <- GetAssayData(object = object, layer = layer, assay = assay) write(colnames(data.tmp), file = cols) write(rownames(data.tmp), file = rows) if(length(meta_columns)){ diff --git a/R/FindDifferentVariants.R b/R/FindDifferentVariants.R index 9a6b097..23dcc09 100644 --- a/R/FindDifferentVariants.R +++ b/R/FindDifferentVariants.R @@ -8,7 +8,7 @@ #' @param min.cells numeric(1). The minimal number of cells that should be have data in both populations for differential testing to be performed. Default: 15. #' @param sort.by character(1). "pval" to sort the result dataframe by p-value, or "deltafreq" to sort by absolute difference in frequency. Any other value will result in no sorting, conserving the feature order in the Seurat object. Default: pval. #' @param assays character(2). The name of the assays in which the reference allele count and alt allele count are stored in the seurat object. Default: c("REF","ALT"). -#' @param slot character(1). The assay slot that should be used in the Seurat object. Default: "data". +#' @param layer character(1). The assay layer that should be used in the Seurat object. Default: "data". #' @param show.progress numeric(1). Number of tests performed between updates on the advance. FALSE or 0 for no progress reports. Default: 500. #' @param pval.lower.limit numeric(1). p-vals lower than this limit will be truncated to this limit. Useful to avoid log(0) and set an axis limit in volcano-like plots of the results. #' @return Returns a data frame with columns "n1" (number of cells with variant data in population 1) and "n2" (same in population 2), the frequency of ref and alt allele in both populations "freq1" and "freq2", the difference in frequency "deltafreq", and the results of the chi-square test for identitical frequency with or without Bonferroni correction "pval" and "adj.pval". @@ -16,7 +16,7 @@ #' @export #' @examples #' DifferentialTestingresults <- FindDifferentVariants(MySeuratObject, "FirstIdentName", "OtherIdentName") -FindDifferentVariants <- function(object, ident.1, ident.2=NULL, min.cells=15, sort.by="pval", assay=c("REF","ALT"), slot="data", show.progress=500, pval.lower.limit=1e-100){ +FindDifferentVariants <- function(object, ident.1, ident.2=NULL, min.cells=15, sort.by="pval", assay=c("REF","ALT"), layer="data", show.progress=500, pval.lower.limit=1e-100){ # Clarify the identities to use if(length(ident.1)==1){ ident.1 <- colnames(object)[Idents(object)==ident.1] @@ -36,10 +36,10 @@ FindDifferentVariants <- function(object, ident.1, ident.2=NULL, min.cells=15, s return(object) } # Pick up the data filtered above min.cell threshold, and aggregate the counts of ref and alt: - variants_ident_1_ref <- GetAssayData(object, assay=assay[1], slot=slot)[,ident.1] - variants_ident_1_alt <- GetAssayData(object, assay=assay[2], slot=slot)[,ident.1] - variants_ident_2_ref <- GetAssayData(object, assay=assay[1], slot=slot)[,ident.2] - variants_ident_2_alt <- GetAssayData(object, assay=assay[2], slot=slot)[,ident.2] + variants_ident_1_ref <- GetAssayData(object, assay=assay[1], layer=layer)[,ident.1] + variants_ident_1_alt <- GetAssayData(object, assay=assay[2], layer=layer)[,ident.1] + variants_ident_2_ref <- GetAssayData(object, assay=assay[1], layer=layer)[,ident.2] + variants_ident_2_alt <- GetAssayData(object, assay=assay[2], layer=layer)[,ident.2] tmp1 <- Matrix::rowSums((variants_ident_1_ref+variants_ident_1_alt)>0) tmp2 <- Matrix::rowSums((variants_ident_2_ref+variants_ident_2_alt)>0) keep <- tmp1>min.cells & tmp2>min.cells diff --git a/R/GatherFeatures.R b/R/GatherFeatures.R index d3dab0e..5e7cbda 100644 --- a/R/GatherFeatures.R +++ b/R/GatherFeatures.R @@ -5,21 +5,21 @@ #' @param object Seurat object. #' @param features character(n). Metadata columns and/or feature names, or assay feature pairs in the form assay_feature. #' @param assay character(1). From which assay should features be pulled from in priority. Default: DefaultAssay. Other typical options depending on the Seurat object: "RNA", "imputed.RNA", "CiteSeq", "HTO" etc. -#' @param slot character(1). From which slot should features be pulled from. Default: "data". Other typical options: "counts", "scale.data". +#' @param layer character(1). From which layer should features be pulled from. Default: "data". Other typical options: "counts", "scale.data". #' @return Returns a data frame with features or signatures / metadata columns as columns and cells as rows, in the same order as the cells/barcodes in the Seurat object. #' @export #' @examples #' df <- GatherFeatures(MySeuratObject,c("nFeature_RNA","RNA_GAPDH")) -GatherFeatures <- function(object, features, assay=DefaultAssay(object), slot="data"){ - # Verify the assay and slot are present in the Seurat object +GatherFeatures <- function(object, features, assay=DefaultAssay(object), layer="data"){ + # Verify the assay and layer are present in the Seurat object if(!assay %in% Assays(object)){ warning("Assay not found in the Seurat object, reverting to default assay") assay <- DefaultAssay(object) } - if(!slot %in% slotNames(object[[assay]])){ - warning("Slot not found in the Seurat object, reverting to data") - slot <- "data" + if(!layer %in% Layers(object[[assay]])){ + warning("Layer not found in the Seurat object, reverting to data") + layer <- "data" } # First pick up anything that can be picked up in the metadata: @@ -36,15 +36,15 @@ GatherFeatures <- function(object, features, assay=DefaultAssay(object), slot="d # Gather the features in the default assay: if(length(signatures_default_assay)){ - df <- cbind(df,t(as.matrix(GetAssayData(object = object, assay = assay, slot = slot)[signatures_default_assay,,drop=F]))) + df <- cbind(df,t(as.matrix(GetAssayData(object = object, assay = assay, layer = layer)[signatures_default_assay,,drop=F]))) } # Gather the features only given by name and not in the default assay: if(length(signatures_without_assay_defined)){ for(j in 1:length(object@assays)){ - tmp <- intersect(signatures_without_assay_defined,rownames(GetAssayData(object = object, assay = Assays(object)[j], slot = slot))) + tmp <- intersect(signatures_without_assay_defined,rownames(GetAssayData(object = object, assay = Assays(object)[j], layer = layer))) if(length(tmp)){ - df <- cbind(df,t(as.matrix(GetAssayData(object = object, assay = Assays(object)[j], slot = slot)[tmp,,drop=F]))) + df <- cbind(df,t(as.matrix(GetAssayData(object = object, assay = Assays(object)[j], layer = layer)[tmp,,drop=F]))) } } } @@ -53,7 +53,7 @@ GatherFeatures <- function(object, features, assay=DefaultAssay(object), slot="d if(length(signatures_with_assay_defined)){ for(i in 1:length(signatures_with_assay_defined)){ tmp <- strsplit(signatures_with_assay_defined[i],"_")[[1]] - defined.feat <- t(as.matrix(GetAssayData(object = object, assay = tmp[1], slot = slot)[tmp[2],,drop=F])) + defined.feat <- t(as.matrix(GetAssayData(object = object, assay = tmp[1], layer = layer)[tmp[2],,drop=F])) df <- cbind(df,defined.feat) colnames(df)[ncol(df)] <- signatures_with_assay_defined[i] } diff --git a/R/IdentPlotQC.R b/R/IdentPlotQC.R index cc7a525..60ababa 100644 --- a/R/IdentPlotQC.R +++ b/R/IdentPlotQC.R @@ -1,6 +1,6 @@ #' QC plot with cell type highlight #' -#' This function makes interactive quality control (QC) plots from a Seurat object, by default percent.mito vs nFeature_RNA, while color-coding various cell types. Any metadata column, signature, or feature can be also be used for the x/y axis. To pick from a particular assay, use an underscore separator, as in "assay_feature" or set the assay parameter. Features are picked up from the data slot by default, set slot to change. +#' This function makes interactive quality control (QC) plots from a Seurat object, by default percent.mito vs nFeature_RNA, while color-coding various cell types. Any metadata column, signature, or feature can be also be used for the x/y axis. To pick from a particular assay, use an underscore separator, as in "assay_feature" or set the assay parameter. Features are picked up from the data layer by default, set layer to change. #' #' Plotly interactions: click on legend categories to toggle the display on/off, double click to isolate one cell type/category/ident. #' Hover to get cell info (useful to choose filtering parameters), and select pan/zoom in the top-right menu to do close-ups and navigate. @@ -16,20 +16,20 @@ #' @param interactive Enable interactive plot? (Default: TRUE). #' @param colors.use For interactive plots, a colorbrewer2.org palette name (e.g. "YlOrRd" or "Blues"), or a vector of colors to interpolate in hexadecimal "#RRGGBB" format, or a color interpolation function like colorRamp(). For non-interactive plots, a vector of colors passed to ggplot2 scale_color_manual. If the vector is named, the values will be matched based on names. #' @param assay character(1). If axes are features rather than metadata columns, the assay from which they should be pulled in priority (Default: DefaultAssay(object)). -#' @param slot character(1). If axes are features rather than metadata columns, the slot from which they should be pulled (Default: "data"). +#' @param layer character(1). If axes are features rather than metadata columns, the layer from which they should be pulled (Default: "data"). #' @param ... Other arguments passed to plot_ly in the case of interactive plots. #' @return If one ident is plotted and interactive is enabled, returns interactive plot (plotly). If several, returns a ggplot grid (cowplot). #' @keywords QC plot with cell types highlighted. #' @export #' @examples -#' # After MySeuratObject has been log-normalized in order to contain an RNA>data assay>slot and been augmented with a percent.mito metadata column: +#' # After MySeuratObject has been log-normalized in order to contain an RNA>data assay>layer and been augmented with a percent.mito metadata column: #' # SignatureList should be a list of character vectors, each containing a series of feature/gene names. In this example, the signatures correspond to cell types, and the name of each signature is the name of the corresponding cell type (e.g. Tcell, Bcell, EpithelialCell, Fibroblasts, etc). #' MySeuratObject <- Impute(MySeuratObject) #' MySeuratObject <- ScoreSignatures(MySeuratObject,SignatureList) #' MySeuratObject <- Classify(MySeuratObject,names(SignatureList),"CellType") # Automatic cell type annotation based on cell type signatures. #' IdentPlotQC(MySeuratObject,"celltype") -IdentPlotQC <- function(object, ident=NA, x= "nFeature_RNA", y="percent.mito", log.scale=TRUE, ncol=NA, pt.size=1, interactive=TRUE, colors.use=NULL, assay=DefaultAssay(object), slot="data", ...){ +IdentPlotQC <- function(object, ident=NA, x= "nFeature_RNA", y="percent.mito", log.scale=TRUE, ncol=NA, pt.size=1, interactive=TRUE, colors.use=NULL, assay=DefaultAssay(object), layer="data", ...){ if(sum(is.na(ident))){ object$tmp <- as.character(Idents(object)) ident <- "tmp" @@ -48,7 +48,7 @@ IdentPlotQC <- function(object, ident=NA, x= "nFeature_RNA", y="percent.mito", l } } - df <- GatherFeatures(object,c(x,y,ident), slot=slot, assay=assay) + df <- GatherFeatures(object,c(x,y,ident), layer=layer, assay=assay) if(length(ident)==0){ warning("No valid ident found. Abort.") return() diff --git a/R/Impute.R b/R/Impute.R index bde509c..86d05a4 100644 --- a/R/Impute.R +++ b/R/Impute.R @@ -1,7 +1,7 @@ #' MAGIC imputation #' #' This function is a wrapper of the MAGIC imputation function to easily impute Seurat objects containing scRNA-seq data, with reasonable default parameters when used in the context of signature scoring for cell classification: only imputing the most variable genes and additional features of interest, and using only 40 PCs for efficiency, and using a narrow neighborhood to avoid over-smoothing. -#' @param object Seurat object. Must contain an RNA assay with a data slot that will be used for imputation. +#' @param object Seurat object. Must contain an RNA assay with a data layer (or a custom layer specified in argument layer.use) that will be used for imputation. #' @param features A subset of features/genes on which to run the imputation. Can be a list of signatures in which the features in the list will be added, or can be "all" (Default: NULL/none, i.e. only impute all variable features if append.variable.features is TRUE, as set by default). #' @param append.variable.features Whether to append the variable features of the active assay in the Seurat object to the list of features to impute (Default: TRUE) #' @param npca Number of principal components to use for imputation (Default: 40). @@ -10,9 +10,9 @@ #' @param n.jobs Number of threads on which to run the imputation (Default: 6). #' @param name Name of the assay storing the imputed data (Default: "imputed"). #' @param assay.use Name of the assay to impute (Default: "RNA"). -#' @param slot.use Name of the slot to impute (Default: "data"). -#' @param name Name of the slot in which the imputed assay is stored (Default: paste0("imputed.",assay.use)). -#' @return Seurat object with an additional slot containing MAGIC imputed data. +#' @param layer.use Name of the layer to impute (Default: "data"). +#' @param name Name of the assay in which the imputed data is stored (Default: paste0("imputed.",assay.use)). +#' @return Seurat object with an additional layer containing MAGIC imputed data. #' @keywords MAGIC Rmagic imputation #' @export #' @examples @@ -20,9 +20,9 @@ #' MySeuratObject[["imputed.RNA"]] #' SL <- list(CD8TC=c("CD3","CD8","-CD4"), #' Fibro=c("VIM","COL1A1","-EPCAM")) -#' MySeuratObject <- Impute(MySeuratObject, features=SL, append.variable.features=TRUE, knn=4, t=3, npca=30, n.jobs=36, assay.use="RNA", slot.use="scale.data", name="custom.imputation") +#' MySeuratObject <- Impute(MySeuratObject, features=SL, append.variable.features=TRUE, knn=4, t=3, npca=30, n.jobs=36, assay.use="RNA", layer.use="scale.data", name="custom.imputation") #' MySeuratObject[["imputed.RNA"]] -Impute <- function(object, features=NULL, append.variable.features=TRUE, npca=40, knn=3, t=2, n.jobs=6, assay.use="RNA", slot.use="data", name=paste0("imputed.",assay.use)){ +Impute <- function(object, features=NULL, append.variable.features=TRUE, npca=40, knn=3, t=2, n.jobs=6, assay.use="RNA", layer.use="data", name=paste0("imputed.",assay.use)){ if(!"Rmagic" %in% rownames(installed.packages())){ stop('Rmagic is not installed, but needed for imputations. Consider running: devtools::install_github("cran/Rmagic"). The python version magic-impute is also needed, see install instructions at https://github.com/cran/Rmagic.') @@ -62,7 +62,7 @@ Impute <- function(object, features=NULL, append.variable.features=TRUE, npca=40 } if(length(features)>0){ - imputed <- Rmagic::magic(data = t(as.matrix(slot(object@assays[[assay.use]],slot.use)[features,])), npca=npca, knn=knn, t=t, n.jobs=n.jobs) + imputed <- Rmagic::magic(data = t(as.matrix(GetAssayData(object, assay=assay.use, layer=layer.use)[features,])), npca=npca, knn=knn, t=t, n.jobs=n.jobs) imputed <- t(imputed$result) object[[name]] <- CreateAssayObject(imputed) DefaultAssay(object) <- backup_default_assay diff --git a/R/NormalizeHTO.R b/R/NormalizeHTO.R index 76ad2db..2e81d9b 100644 --- a/R/NormalizeHTO.R +++ b/R/NormalizeHTO.R @@ -10,7 +10,7 @@ #' @param assay character(1). The name of the assay which should be normalized. Default: "HTO". #' @param q numeric(1). Only used if scale.HTO="quantile". The quantile used for normalization. #' @param imputed.assay character(1). Only used if scale.HTO="imputed_max". The name of the assay that contains imputed HTO data. -#' @return Returns a Seurat object with normalized HTO data in the data slot. +#' @return Returns a Seurat object with normalized HTO data in the data layer. #' @keywords HTO normalization #' @export #' @examples @@ -47,7 +47,7 @@ NormalizeHTO <- function(object, scale.HTO = "stdev", normalize.cells = 100, ass HTO_counts <- sweep(HTO_counts, 2, matrixStats::colSums2(as.matrix(HTO_counts)), FUN = '/') # Scale each col (cbc) to its sum. HTO_counts <- HTO_counts*normalize.cells } - object[["HTO"]]@data <- as(HTO_counts,"dgCMatrix") + object[["HTO"]]$data <- as(HTO_counts,"dgCMatrix") return(object) } diff --git a/R/PseudoBulkGenotypes.R b/R/PseudoBulkGenotypes.R index a842ff3..2133fb4 100644 --- a/R/PseudoBulkGenotypes.R +++ b/R/PseudoBulkGenotypes.R @@ -6,13 +6,13 @@ #' @param ident character(n). The name of a metadata column, or a vector listing the individual identities of cells, or a list of cells. Defines the groups of cells that are aggregated in pseudo-bulk genotypes. Default: Idents(object). #' @param tolerance.pct numeric(1). The percentage of counts not matching the rest tolerated to keep a homozygous call. #' @param assays character(3). The name of the assays in which the consensus matrix (expected to also contain variant metadata), reference allele count and alt allele count are stored in the seurat object. Default: c("VAR","REF","ALT"). -#' @param slot character(1). The assay slot that should be used in the Seurat object. Default: "data". +#' @param layer character(1). The assay layer that should be used in the Seurat object. Default: "data". #' @return Returns a genotype object with the aggregated pseudo-bulk genotypes and their metadata. #' @keywords pseudo-bulk Pseudobulk genotype aggregation #' @export #' @examples #' GenotypeObject <- PseudoBulkGenotypes(MySeuratObject) -PseudoBulkGenotypes <- function(object, ident=Idents(object), tolerance.pct=5, assays=c("VAR","REF","ALT"), slot="data"){ +PseudoBulkGenotypes <- function(object, ident=Idents(object), tolerance.pct=5, assays=c("VAR","REF","ALT"), layer="data"){ # Clarify the identities to use if(!length(ident)){ print("No cluster identity given, using default Idents(object)") @@ -58,8 +58,8 @@ PseudoBulkGenotypes <- function(object, ident=Idents(object), tolerance.pct=5, a # Go through the clusters, pick up the data, aggregate, compute coverage, frequency, and make a genotype call: tol <- tolerance.pct/100 for(i in gt.names){ - ref <- Matrix::rowSums(GetAssayData(object, assay=assays[2], slot=slot)[,idents==i]) - alt <- Matrix::rowSums(GetAssayData(object, assay=assays[3], slot=slot)[,idents==i]) + ref <- Matrix::rowSums(GetAssayData(object, assay=assays[2], layer=layer)[,idents==i]) + alt <- Matrix::rowSums(GetAssayData(object, assay=assays[3], layer=layer)[,idents==i]) cvg <- ref+alt freq <- alt/cvg + 1 # Offset by one to distinguish no data from 0 frequency freq[cvg==0] <- 0 diff --git a/R/RunMDS.R b/R/RunMDS.R index e033f86..625ef2c 100644 --- a/R/RunMDS.R +++ b/R/RunMDS.R @@ -1,6 +1,6 @@ #' Run MDS #' -#' Compute a multidimensional scaling (MDS) dimensionality reduction on a Seurat object, using the provided distance metric. By default, using 30 dimensions in the reduced space, based on the variable features of the current default assay and data slot, with results stored under the name "mds". +#' Compute a multidimensional scaling (MDS) dimensionality reduction on a Seurat object, using the provided distance metric. By default, using 30 dimensions in the reduced space, based on the variable features of the current default assay and data layer, with results stored under the name "mds". #' #' Wrapper of the bigmds divide and conquer method, see [bigmds::divide_conquer_mds()] for details and references. #' @@ -13,7 +13,7 @@ #' @param n.dims numeric(1). The number of dimensions in the reduction (Default:30). #' @param features.use character(n). The features to use to compute the reduction. NA for most variable features of assay (Default: NA). #' @param assay character(1). The assay to use. NA uses "VAR" if available, otherwise the DefaultAssay (Default:NA). -#' @param slot character(1). The Seurat object assay slot to use (Default:"data"). +#' @param layer character(1). The Seurat object assay layer to use (Default:"data"). #' @param reduction.name character(1). The name under which the dimensionality reduction will be stored under (Default: "mds"). #' @param key character(1). The key (prefix to column numbers) used to name the MDS coordinates (Default: "MDS_") #' @param batch_size numeric(1). The number of cells processed for each batch of the divide and conquer MDS. The batches are then realigned and merged. Smaller batches provide faster runs, larger batches provide more accurate results (Default: 400). @@ -28,7 +28,7 @@ #' DimPlot(MySeuratObject, reduction="mds") #' MySeuratObject <- RunUMAP(MySeuratObject,reduction="mds",dims=1:30) #' DimPlot(MySeuratObject, reduction="umap") -RunMDS <- function(object, distance=NA, n.dims = 30, features.use = NA, assay=NA, slot="data", reduction.name="mds", key="MDS_", batch_size=400, n.cores=1, seed = 42){ +RunMDS <- function(object, distance=NA, n.dims = 30, features.use = NA, assay=NA, layer="data", reduction.name="mds", key="MDS_", batch_size=400, n.cores=1, seed = 42){ set.seed(seed) # Resolve the assay to use: @@ -66,7 +66,7 @@ RunMDS <- function(object, distance=NA, n.dims = 30, features.use = NA, assay=NA } # MDS with divide and conquer method: - mds <- bigmds::divide_conquer_mds(x = Matrix::t(GetAssayData(object, assay = assay, slot = slot)[features.use,]), l = batch_size, c_points = 2*n.dims, r = n.dims, n_cores = n.cores, dist_fn = distance) + mds <- bigmds::divide_conquer_mds(x = Matrix::t(GetAssayData(object, assay = assay, layer = layer)[features.use,]), l = batch_size, c_points = 2*n.dims, r = n.dims, n_cores = n.cores, dist_fn = distance) object[[reduction.name]] <- CreateDimReducObject(key = key, stdev = mds$eigen, assay = assay, embeddings = matrix(data = mds$points, nrow = nrow(mds$points), ncol = ncol(mds$points), dimnames = list(colnames(object),paste0(key,1:n.dims)))) return(object) } diff --git a/R/ScoreSignature.R b/R/ScoreSignature.R index c935bde..7d6826e 100644 --- a/R/ScoreSignature.R +++ b/R/ScoreSignature.R @@ -3,14 +3,14 @@ #' This function scores a signature at the single cell level on Seurat objects (sum of the expression for each cell). #' The signature must be a list of features (character vector). #' Any feature can be set as a negative marker in the scoring by prefixing it with a minus sign, e.g. "-EPCAM". -#' By default, the score is computed as the average expression of the features as normalized in the "data" slot (i.e. log-normalized typically). Can be overrun by setting the slot.use parameter. +#' By default, the score is computed as the average expression of the features as normalized in the "data" layer (i.e. log-normalized typically). Can be overrun by setting the layer.use parameter. #' If imputed data is available (assay "imputed.RNA"), the imputed data will be used. Otherwise, data from the RNA assay will be used. This can be overrun by setting the assay.use parameter. #' @param object Seurat object. #' @param features The signature, typically a gene list (character vector). Negative features are prefixed by a minus sign as in "-EPCAM". #' @param name The name of the signature (character). The single cell scores are added to the Seurat object metadata in a column with this name, and can be accessed as object$name or displayed with FeaturePlot(object,name). #' @param assay.use The assay within the Seurat object to use for signature scoring. If NA (default), it will use the "imputed" assay if it is present, or the "RNA" assay otherwise. -#' @param slot.use The slot to use within the assay to get data for signature scoring. By default, using the "data" assay. -#' @return Seurat object with an additional metadata slot containing the signature score. +#' @param layer.use The layer to use within the assay to get data for signature scoring. By default, using the "data" assay. +#' @return Seurat object with an additional metadata column containing the signature score. #' @keywords Signature Scoring #' @examples #' #Scoring a single signature @@ -20,7 +20,7 @@ #' FeaturePlot(MySeuratObject,"EpithelialSignature") #' @export #' -ScoreSignature <- function(object, features, name = "Signature", assay.use=NA, slot.use="data"){ +ScoreSignature <- function(object, features, name = "Signature", assay.use=NA, layer.use="data"){ print(paste0("Scoring the signature: ",name)) if(is.na(assay.use)){ if("imputed.RNA" %in% names(object@assays)){ @@ -33,20 +33,20 @@ ScoreSignature <- function(object, features, name = "Signature", assay.use=NA, s warning("No imputed.RNA or RNA assay found in the Seurat object. Explicitely provide an assay.") } } - features.positive <- intersect(features,rownames(slot(object[[assay.use]],slot.use))) - features.negative <- intersect(unlist(lapply(strsplit(grep("^-",features,value=T),"^-"),`[`,2)),rownames(slot(object[[assay.use]],slot.use))) + features.positive <- intersect(features,rownames(GetAssayData(object, assay=assay.use, layer=layer.use))) + features.negative <- intersect(unlist(lapply(strsplit(grep("^-",features,value=T),"^-"),`[`,2)),rownames(GetAssayData(object, assay=assay.use, layer=layer.use))) - missing.features <- setdiff(GetAllSignatureGenes(features), rownames(slot(object[[assay.use]],slot.use))) + missing.features <- setdiff(GetAllSignatureGenes(features), rownames(GetAssayData(object, assay=assay.use, layer=layer.use))) if(length(missing.features)>0){ print(paste("Missing features assumed null:",toString(missing.features))) } if(length(features.positive)){ - scores.positive <- Matrix::colSums(rbind(slot(object[[assay.use]],slot.use)[features.positive,],0))/length(features) # Concatenate a line of zeros because colSums doesn't deal with one-line matrices. + scores.positive <- Matrix::colSums(rbind(GetAssayData(object, assay=assay.use, layer=layer.use)[features.positive,],0))/length(features) # Concatenate a line of zeros because colSums doesn't deal with one-line matrices. }else{ scores.positive <- 0 } if(length(features.negative)){ - scores.negative <- Matrix::colSums(rbind(slot(object[[assay.use]],slot.use)[features.negative,],0))/length(features) + scores.negative <- Matrix::colSums(rbind(GetAssayData(object, assay=assay.use, layer=layer.use)[features.negative,],0))/length(features) }else{ scores.negative <- 0 } @@ -58,14 +58,14 @@ ScoreSignature <- function(object, features, name = "Signature", assay.use=NA, s #' Multiple signature scoring on Seurat objects #' #' This function scores multiple signatures at the single cell level on a Seurat object (sum of the expression for each cell and signature). -#' By default, the score is computed as the average expression of the features as normalized in the "data" slot (i.e. log-normalized typically). Can be overrun by setting the slot.use parameter. +#' By default, the score is computed as the average expression of the features as normalized in the "data" layer (i.e. log-normalized typically). Can be overrun by setting the layer.use parameter. #' Any feature can be set as a negative marker in the scoring by prefixing it with a minus sign, e.g. "-EPCAM". #' If imputed data is available (assay "imputed"), the imputed data will be used. Otherwise, data from the RNA assay will be used. This can be overrun by setting the assay paramter. #' @param object Seurat object. #' @param signature.list The named list of signatures. Each element of the list is a signature (character vector), the names of the elements in the list will be used as signature names. #' @param assay.use The assay within the Seurat object to use for signature scoring. If NA (default), it will use the "imputed" assay if it is present, or the "RNA" assay otherwise. -#' @param slot.use The slot to use within the assay to get data for signature scoring. By default, using the "data" assay. -#' @return Seurat object with additional metadata slots containing signature scores. +#' @param layer.use The layer to use within the assay to get data for signature scoring. By default, using the "data" assay. +#' @return Seurat object with additional metadata layers containing signature scores. #' @keywords Multiple Signature Scoring #' @examples #' signature.list <- list(EpithelialSignature=c("EPCAM","CDH1","ITGA6"), FibroSignature=c("VIM","COL1A1","ITGA1","-EPCAM")) @@ -76,9 +76,9 @@ ScoreSignature <- function(object, features, name = "Signature", assay.use=NA, s #' FeaturePlot(MySeuratObject,c("EpithelialSignature","FibroSignature")) #' @export -ScoreSignatures <- function(object, signature.list, assay.use=NA, slot.use="data"){ +ScoreSignatures <- function(object, signature.list, assay.use=NA, layer.use="data"){ for(i in names(signature.list)){ - object <- ScoreSignature(object, signature.list[[i]], i, assay.use=assay.use, slot.use=slot.use) + object <- ScoreSignature(object, signature.list[[i]], i, assay.use=assay.use, layer.use=layer.use) } return(object) } diff --git a/R/SignaturePlotQC.R b/R/SignaturePlotQC.R index ee46963..c5edab4 100644 --- a/R/SignaturePlotQC.R +++ b/R/SignaturePlotQC.R @@ -13,19 +13,19 @@ #' @param ncol num(1). Number of columns (Default = NA, determined from the data) #' @param pt.size num(1). The point size, passed to ggplot (Default: 1) #' @param assay character(1). If some values to highlight are features rather than metadata columns, the assay from which they should be pulled in priority (Default: DefaultAssay(object)). -#' @param slot character(1). If some values to highlight are features rather than metadata columns, the slot from which they should be pulled (Default: "data"). +#' @param layer character(1). If some values to highlight are features rather than metadata columns, the layer from which they should be pulled (Default: "data"). #' @return Returns a ggplot/cowplot grid object. #' @keywords QC plot signatures highlight #' @export #' @examples -#' # After MySeuratObject has been log-normalized in order to contain an RNA>data assay>slot and been augmented with a percent.mito metadata column: +#' # After MySeuratObject has been log-normalized in order to contain an RNA>data assay>layer and been augmented with a percent.mito metadata column: #' # SignatureList should be a list of character vectors, each containing a series of feature/gene names. #' MySeuratObject <- Impute(MySeuratObject) #' MySeuratObject <- ScoreSignatures(MySeuratObject,SignatureList) #' SignaturePlotQC(MySeuratObject,names(SignatureList)) #' SignaturePlotQC(MySeuratObject,x="MKI67",y="PCNA",log.scale=FALSE,pt.size=1.5,) -SignaturePlotQC <- function(object, signatures, x= "nFeature_RNA", y="percent.mito", log.scale=TRUE, ncol=NA, pt.size=1, assay=DefaultAssay(object), slot="data"){ +SignaturePlotQC <- function(object, signatures, x= "nFeature_RNA", y="percent.mito", log.scale=TRUE, ncol=NA, pt.size=1, assay=DefaultAssay(object), layer="data"){ if(is.list(signatures)){ if(length(unlist(signatures))==length(signatures)){ sign.names <- unlist(signatures) @@ -55,7 +55,7 @@ SignaturePlotQC <- function(object, signatures, x= "nFeature_RNA", y="percent.mi # warning("The format of the 'signatures' argument (i.e. ",typeof(signatures),") is not supported. Provide a vector of metadata/feature/signature names, or a named signature list.") # return() # } - df <- GatherFeatures(object,c(x,y,sign.names), slot=slot, assay=assay) + df <- GatherFeatures(object,c(x,y,sign.names), layer=layer, assay=assay) p <- list() for(n in sign.names){ if(log.scale){ diff --git a/man/CellSimilarityToGenotypes.Rd b/man/CellSimilarityToGenotypes.Rd index 86f7f3b..6af8419 100644 --- a/man/CellSimilarityToGenotypes.Rd +++ b/man/CellSimilarityToGenotypes.Rd @@ -11,7 +11,7 @@ CellSimilarityToGenotypes( prefix = "Similarity-", features.use = "all", assays = c("VAR", "REF", "ALT"), - slots = c("data", "data", "data") + layers = c("data", "data", "data") ) } \arguments{ @@ -27,7 +27,7 @@ CellSimilarityToGenotypes( \item{assays}{character(3). The name of the assays within the Seurat object that contain the variant calls (sparse matrix with values 1,2,3 in vartrix conventions), and counts of reference and alt alleles (Default: c("VAR","REF","ALT")).} -\item{slots.}{The slots to use within the assays above (Default: c("data","data","data")).} +\item{layers}{The layers to use within the assays above (Default: c("data","data","data")).} } \value{ Returns the Seurat object diff --git a/man/Classify.Rd b/man/Classify.Rd index c00b481..9fbd561 100644 --- a/man/Classify.Rd +++ b/man/Classify.Rd @@ -11,7 +11,7 @@ Classify( metadata.name = "celltype", cell.names = NA, assay = DefaultAssay(object), - slot = "data", + layer = "data", restrict.ident = "Default", restrict.to = as.character(unique(Idents(object))), by.clusters = NULL @@ -30,7 +30,7 @@ Classify( \item{assay}{character(1). If some signatures used for classification are stored as assay features, which assay should be used in priority (Default: DefaultAssay(object)).} -\item{slot}{character(1). If some signatures used for classification are stored as assay features, which slot should be used (Default: "data").} +\item{layer}{character(1). If some signatures used for classification are stored as assay features, which layer should be used (Default: "data").} \item{restrict.ident}{character(1). The name of a metadata column containing celltype annotations, which will be used to define the subset of cells that should be classified. Default: "Default", which uses current default, i.e. Idents(object).} @@ -50,7 +50,7 @@ Each single cell will be associated to the cell type whose signature is maximal If the by.clusters parameter is set to some identities or metadata column containing identities, the classification will be done on clusters rather than single cells. This can help to overcome strong noise, or to take into account some prior knowledge such as dataset alignment in the classification. } \examples{ -# After MySeuratObject has been log-normalized in order to contain an RNA>data assay>slot and been augmented with a percent.mito metadata column: +# After MySeuratObject has been log-normalized in order to contain an RNA>data assay>layer and been augmented with a percent.mito metadata column: # SignatureList should be a list of character vectors, each containing a series of feature/gene names. In this example, the signatures correspond to cell types, and the name of each signature is the name of the corresponding cell type (e.g. Tcell, Bcell, EpithelialCell, Fibroblasts, etc). MySeuratObject <- Impute(MySeuratObject) MySeuratObject <- ScoreSignatures(MySeuratObject,SignatureList) diff --git a/man/ClassifyManual.Rd b/man/ClassifyManual.Rd index aadbfeb..c8c9c0f 100644 --- a/man/ClassifyManual.Rd +++ b/man/ClassifyManual.Rd @@ -9,7 +9,7 @@ ClassifyManual( gates, metadata.name = "celltype", assay = DefaultAssay(object), - slot = "data", + layer = "data", restrict.ident = "Default", restrict.to = as.character(unique(Idents(object))), unclassified.name = "None", @@ -25,7 +25,7 @@ ClassifyManual( \item{assay}{character(1). If some signatures used for classification are stored as assay features, which assay should be used in priority (Default: DefaultAssay(object)).} -\item{slot}{character(1). If some signatures used for classification are stored as assay features, which slot should be used (Default: "data").} +\item{layer}{character(1). If some signatures used for classification are stored as assay features, which layer should be used (Default: "data").} \item{restrict.ident}{character(1). The name of a metadata column containing celltype annotations, which will be used to define the subset of cells that should be classified. Default: current Idents(object).} @@ -54,7 +54,7 @@ Scores are taken from the metadata in priority, otherwise from assays. If found Since single cell data tends to be noisy and have a significant amount of dropouts, imputation is usually a great combination with gating strategies, in a similar fashion to gaussian filtering needed before thresholding in most image analysis workflows. For this, see Impute() and CrossImpute(). } \examples{ -# MySeuratObject should contain an RNA slot with log-normalized data assay. +# MySeuratObject should contain an RNA layer with log-normalized data assay. # In this example cells are classified as T cells (TC) or Epithelial cells (EP) based on manual signatures. # Note that cells that validate no gate will have cell type "None", and cells which validate several will be classified as "Multiplets". # It's recommended to first do a signature scatter plot in order to choose threshold values for the gates. diff --git a/man/CrossImpute.Rd b/man/CrossImpute.Rd index c8488de..bf1fe8d 100644 --- a/man/CrossImpute.Rd +++ b/man/CrossImpute.Rd @@ -15,7 +15,7 @@ CrossImpute( knn = 3, t = 2, n.jobs = 6, - slot.use = "data" + layer.use = "data" ) } \arguments{ @@ -39,10 +39,10 @@ CrossImpute( \item{n.jobs}{integer(1). Number of threads on which to run the imputation (Default: 6).} -\item{slot.use}{character(1). Name of the slot to impute (Default: "data").} +\item{layer.use}{character(1). Name of the layer to impute (Default: "data").} } \value{ -Seurat object with an additional slot containing MAGIC cross-imputed data. +Seurat object with an additional layer containing MAGIC cross-imputed data. } \description{ This function imputes features in an assay based on (the merger with) another assay. Typically using the high resolution in the RNA data to impute more noisy additional assays. diff --git a/man/Export10X.Rd b/man/Export10X.Rd index fae9df4..e8776a8 100644 --- a/man/Export10X.Rd +++ b/man/Export10X.Rd @@ -14,7 +14,7 @@ Export10X( cols = "barcodes.tsv", counts = "matrix.mtx", meta = "metadata.tsv", - slot = "counts", + layer = "counts", assay = "RNA" ) } @@ -37,7 +37,7 @@ Export10X( \item{meta}{character(1). Name of the exported file that contains the metadata. Default: metadata.tsv} -\item{slot}{character(1). Name of the slot in the Seurat object from which the count matrix is exported. Default: counts} +\item{layer}{character(1). Name of the layer in the Seurat object from which the count matrix is exported. Default: counts} \item{assay}{character(1). Name of the assay in the Seurat object from which the count matrix is exported. Default: RNA} } @@ -50,7 +50,7 @@ Export10X(SeuratObject, "MyDir") # Include only two custom metadata columns, two dimensionality reductions, and do not compress the matrices. Export10X(SeuratObject, "MyDir", c("nFeature_RNA", "mito.content"), c("pca","umap"), gzip=FALSE) # Export normalized CiteSeq data rather than raw RNA counts, and no metadata: -Export10X(SeuratObject, "MyDir", meta_columns = c(), slot="data", assay="CiteSeq") +Export10X(SeuratObject, "MyDir", meta_columns = c(), layer="data", assay="CiteSeq") } \keyword{10X} \keyword{Reexport} diff --git a/man/FindDifferentVariants.Rd b/man/FindDifferentVariants.Rd index d1ef399..65fe5cd 100644 --- a/man/FindDifferentVariants.Rd +++ b/man/FindDifferentVariants.Rd @@ -11,7 +11,7 @@ FindDifferentVariants( min.cells = 15, sort.by = "pval", assay = c("REF", "ALT"), - slot = "data", + layer = "data", show.progress = 500, pval.lower.limit = 1e-100 ) @@ -27,7 +27,7 @@ FindDifferentVariants( \item{sort.by}{character(1). "pval" to sort the result dataframe by p-value, or "deltafreq" to sort by absolute difference in frequency. Any other value will result in no sorting, conserving the feature order in the Seurat object. Default: pval.} -\item{slot}{character(1). The assay slot that should be used in the Seurat object. Default: "data".} +\item{layer}{character(1). The assay layer that should be used in the Seurat object. Default: "data".} \item{show.progress}{numeric(1). Number of tests performed between updates on the advance. FALSE or 0 for no progress reports. Default: 500.} diff --git a/man/GatherFeatures.Rd b/man/GatherFeatures.Rd index af8dfe1..fbd3ae9 100644 --- a/man/GatherFeatures.Rd +++ b/man/GatherFeatures.Rd @@ -4,7 +4,7 @@ \alias{GatherFeatures} \title{Gather features} \usage{ -GatherFeatures(object, features, assay = DefaultAssay(object), slot = "data") +GatherFeatures(object, features, assay = DefaultAssay(object), layer = "data") } \arguments{ \item{object}{Seurat object.} @@ -13,7 +13,7 @@ GatherFeatures(object, features, assay = DefaultAssay(object), slot = "data") \item{assay}{character(1). From which assay should features be pulled from in priority. Default: DefaultAssay. Other typical options depending on the Seurat object: "RNA", "imputed.RNA", "CiteSeq", "HTO" etc.} -\item{slot}{character(1). From which slot should features be pulled from. Default: "data". Other typical options: "counts", "scale.data".} +\item{layer}{character(1). From which layer should features be pulled from. Default: "data". Other typical options: "counts", "scale.data".} } \value{ Returns a data frame with features or signatures / metadata columns as columns and cells as rows, in the same order as the cells/barcodes in the Seurat object. diff --git a/man/IdentPlotQC.Rd b/man/IdentPlotQC.Rd index fe1ccd6..86c37b4 100644 --- a/man/IdentPlotQC.Rd +++ b/man/IdentPlotQC.Rd @@ -15,7 +15,7 @@ IdentPlotQC( interactive = TRUE, colors.use = NULL, assay = DefaultAssay(object), - slot = "data", + layer = "data", ... ) } @@ -40,7 +40,7 @@ IdentPlotQC( \item{assay}{character(1). If axes are features rather than metadata columns, the assay from which they should be pulled in priority (Default: DefaultAssay(object)).} -\item{slot}{character(1). If axes are features rather than metadata columns, the slot from which they should be pulled (Default: "data").} +\item{layer}{character(1). If axes are features rather than metadata columns, the layer from which they should be pulled (Default: "data").} \item{...}{Other arguments passed to plot_ly in the case of interactive plots.} } @@ -48,7 +48,7 @@ IdentPlotQC( If one ident is plotted and interactive is enabled, returns interactive plot (plotly). If several, returns a ggplot grid (cowplot). } \description{ -This function makes interactive quality control (QC) plots from a Seurat object, by default percent.mito vs nFeature_RNA, while color-coding various cell types. Any metadata column, signature, or feature can be also be used for the x/y axis. To pick from a particular assay, use an underscore separator, as in "assay_feature" or set the assay parameter. Features are picked up from the data slot by default, set slot to change. +This function makes interactive quality control (QC) plots from a Seurat object, by default percent.mito vs nFeature_RNA, while color-coding various cell types. Any metadata column, signature, or feature can be also be used for the x/y axis. To pick from a particular assay, use an underscore separator, as in "assay_feature" or set the assay parameter. Features are picked up from the data layer by default, set layer to change. } \details{ Plotly interactions: click on legend categories to toggle the display on/off, double click to isolate one cell type/category/ident. @@ -57,7 +57,7 @@ Hover to get cell info (useful to choose filtering parameters), and select pan/z This is useful when making scRNA-seq from heterogeneous samples: for example immune cells are small and might be discarded as debris from much larger epithelial cancer cells if one is not aware of the differences in QC parameters occuring between various cell types. } \examples{ -# After MySeuratObject has been log-normalized in order to contain an RNA>data assay>slot and been augmented with a percent.mito metadata column: +# After MySeuratObject has been log-normalized in order to contain an RNA>data assay>layer and been augmented with a percent.mito metadata column: # SignatureList should be a list of character vectors, each containing a series of feature/gene names. In this example, the signatures correspond to cell types, and the name of each signature is the name of the corresponding cell type (e.g. Tcell, Bcell, EpithelialCell, Fibroblasts, etc). MySeuratObject <- Impute(MySeuratObject) MySeuratObject <- ScoreSignatures(MySeuratObject,SignatureList) diff --git a/man/Impute.Rd b/man/Impute.Rd index f10ba2c..8b5a02a 100644 --- a/man/Impute.Rd +++ b/man/Impute.Rd @@ -13,12 +13,12 @@ Impute( t = 2, n.jobs = 6, assay.use = "RNA", - slot.use = "data", + layer.use = "data", name = paste0("imputed.", assay.use) ) } \arguments{ -\item{object}{Seurat object. Must contain an RNA assay with a data slot that will be used for imputation.} +\item{object}{Seurat object. Must contain an RNA assay with a data layer (or a custom layer specified in argument layer.use) that will be used for imputation.} \item{features}{A subset of features/genes on which to run the imputation. Can be a list of signatures in which the features in the list will be added, or can be "all" (Default: NULL/none, i.e. only impute all variable features if append.variable.features is TRUE, as set by default).} @@ -34,12 +34,12 @@ Impute( \item{assay.use}{Name of the assay to impute (Default: "RNA").} -\item{slot.use}{Name of the slot to impute (Default: "data").} +\item{layer.use}{Name of the layer to impute (Default: "data").} -\item{name}{Name of the slot in which the imputed assay is stored (Default: paste0("imputed.",assay.use)).} +\item{name}{Name of the assay in which the imputed data is stored (Default: paste0("imputed.",assay.use)).} } \value{ -Seurat object with an additional slot containing MAGIC imputed data. +Seurat object with an additional layer containing MAGIC imputed data. } \description{ This function is a wrapper of the MAGIC imputation function to easily impute Seurat objects containing scRNA-seq data, with reasonable default parameters when used in the context of signature scoring for cell classification: only imputing the most variable genes and additional features of interest, and using only 40 PCs for efficiency, and using a narrow neighborhood to avoid over-smoothing. @@ -49,7 +49,7 @@ MySeuratObject <- Impute(MySeuratObject) MySeuratObject[["imputed.RNA"]] SL <- list(CD8TC=c("CD3","CD8","-CD4"), Fibro=c("VIM","COL1A1","-EPCAM")) -MySeuratObject <- Impute(MySeuratObject, features=SL, append.variable.features=TRUE, knn=4, t=3, npca=30, n.jobs=36, assay.use="RNA", slot.use="scale.data", name="custom.imputation") +MySeuratObject <- Impute(MySeuratObject, features=SL, append.variable.features=TRUE, knn=4, t=3, npca=30, n.jobs=36, assay.use="RNA", layer.use="scale.data", name="custom.imputation") MySeuratObject[["imputed.RNA"]] } \keyword{MAGIC} diff --git a/man/NormalizeHTO.Rd b/man/NormalizeHTO.Rd index 23b45d0..cdde247 100644 --- a/man/NormalizeHTO.Rd +++ b/man/NormalizeHTO.Rd @@ -27,7 +27,7 @@ NormalizeHTO( \item{imputed.assay}{character(1). Only used if scale.HTO="imputed_max". The name of the assay that contains imputed HTO data.} } \value{ -Returns a Seurat object with normalized HTO data in the data slot. +Returns a Seurat object with normalized HTO data in the data layer. } \description{ Normalizes hashtag oligo (HTO) data. By default, first scales each HTO to its standard deviation to account for difference of intensity for the various labels, then scales each cell so that HTO are reported as a percentage. Alternatively, can scale the HTOs to a quantile of their values, to the background value, or to their max after imputation. diff --git a/man/PseudoBulkGenotypes.Rd b/man/PseudoBulkGenotypes.Rd index 9ba1ba4..fb69bc3 100644 --- a/man/PseudoBulkGenotypes.Rd +++ b/man/PseudoBulkGenotypes.Rd @@ -9,7 +9,7 @@ PseudoBulkGenotypes( ident = Idents(object), tolerance.pct = 5, assays = c("VAR", "REF", "ALT"), - slot = "data" + layer = "data" ) } \arguments{ @@ -21,7 +21,7 @@ PseudoBulkGenotypes( \item{assays}{character(3). The name of the assays in which the consensus matrix (expected to also contain variant metadata), reference allele count and alt allele count are stored in the seurat object. Default: c("VAR","REF","ALT").} -\item{slot}{character(1). The assay slot that should be used in the Seurat object. Default: "data".} +\item{layer}{character(1). The assay layer that should be used in the Seurat object. Default: "data".} } \value{ Returns a genotype object with the aggregated pseudo-bulk genotypes and their metadata. diff --git a/man/RunMDS.Rd b/man/RunMDS.Rd index 53d736c..0a97463 100644 --- a/man/RunMDS.Rd +++ b/man/RunMDS.Rd @@ -10,7 +10,7 @@ RunMDS( n.dims = 30, features.use = NA, assay = NA, - slot = "data", + layer = "data", reduction.name = "mds", key = "MDS_", batch_size = 400, @@ -29,7 +29,7 @@ RunMDS( \item{assay}{character(1). The assay to use. NA uses "VAR" if available, otherwise the DefaultAssay (Default:NA).} -\item{slot}{character(1). The Seurat object assay slot to use (Default:"data").} +\item{layer}{character(1). The Seurat object assay layer to use (Default:"data").} \item{reduction.name}{character(1). The name under which the dimensionality reduction will be stored under (Default: "mds").} @@ -45,7 +45,7 @@ RunMDS( Returns the Seurat object. } \description{ -Compute a multidimensional scaling (MDS) dimensionality reduction on a Seurat object, using the provided distance metric. By default, using 30 dimensions in the reduced space, based on the variable features of the current default assay and data slot, with results stored under the name "mds". +Compute a multidimensional scaling (MDS) dimensionality reduction on a Seurat object, using the provided distance metric. By default, using 30 dimensions in the reduced space, based on the variable features of the current default assay and data layer, with results stored under the name "mds". } \details{ Wrapper of the bigmds divide and conquer method, see \code{\link[bigmds:divide_conquer_mds]{bigmds::divide_conquer_mds()}} for details and references. diff --git a/man/ScoreSignature.Rd b/man/ScoreSignature.Rd index 528c525..2309a9c 100644 --- a/man/ScoreSignature.Rd +++ b/man/ScoreSignature.Rd @@ -9,7 +9,7 @@ ScoreSignature( features, name = "Signature", assay.use = NA, - slot.use = "data" + layer.use = "data" ) } \arguments{ @@ -21,16 +21,16 @@ ScoreSignature( \item{assay.use}{The assay within the Seurat object to use for signature scoring. If NA (default), it will use the "imputed" assay if it is present, or the "RNA" assay otherwise.} -\item{slot.use}{The slot to use within the assay to get data for signature scoring. By default, using the "data" assay.} +\item{layer.use}{The layer to use within the assay to get data for signature scoring. By default, using the "data" assay.} } \value{ -Seurat object with an additional metadata slot containing the signature score. +Seurat object with an additional metadata column containing the signature score. } \description{ This function scores a signature at the single cell level on Seurat objects (sum of the expression for each cell). The signature must be a list of features (character vector). Any feature can be set as a negative marker in the scoring by prefixing it with a minus sign, e.g. "-EPCAM". -By default, the score is computed as the average expression of the features as normalized in the "data" slot (i.e. log-normalized typically). Can be overrun by setting the slot.use parameter. +By default, the score is computed as the average expression of the features as normalized in the "data" layer (i.e. log-normalized typically). Can be overrun by setting the layer.use parameter. If imputed data is available (assay "imputed.RNA"), the imputed data will be used. Otherwise, data from the RNA assay will be used. This can be overrun by setting the assay.use parameter. } \examples{ diff --git a/man/ScoreSignatures.Rd b/man/ScoreSignatures.Rd index f6c0033..7d331e3 100644 --- a/man/ScoreSignatures.Rd +++ b/man/ScoreSignatures.Rd @@ -4,7 +4,7 @@ \alias{ScoreSignatures} \title{Multiple signature scoring on Seurat objects} \usage{ -ScoreSignatures(object, signature.list, assay.use = NA, slot.use = "data") +ScoreSignatures(object, signature.list, assay.use = NA, layer.use = "data") } \arguments{ \item{object}{Seurat object.} @@ -13,14 +13,14 @@ ScoreSignatures(object, signature.list, assay.use = NA, slot.use = "data") \item{assay.use}{The assay within the Seurat object to use for signature scoring. If NA (default), it will use the "imputed" assay if it is present, or the "RNA" assay otherwise.} -\item{slot.use}{The slot to use within the assay to get data for signature scoring. By default, using the "data" assay.} +\item{layer.use}{The layer to use within the assay to get data for signature scoring. By default, using the "data" assay.} } \value{ -Seurat object with additional metadata slots containing signature scores. +Seurat object with additional metadata layers containing signature scores. } \description{ This function scores multiple signatures at the single cell level on a Seurat object (sum of the expression for each cell and signature). -By default, the score is computed as the average expression of the features as normalized in the "data" slot (i.e. log-normalized typically). Can be overrun by setting the slot.use parameter. +By default, the score is computed as the average expression of the features as normalized in the "data" layer (i.e. log-normalized typically). Can be overrun by setting the layer.use parameter. Any feature can be set as a negative marker in the scoring by prefixing it with a minus sign, e.g. "-EPCAM". If imputed data is available (assay "imputed"), the imputed data will be used. Otherwise, data from the RNA assay will be used. This can be overrun by setting the assay paramter. } diff --git a/man/SignaturePlotQC.Rd b/man/SignaturePlotQC.Rd index 0d249ae..471500c 100644 --- a/man/SignaturePlotQC.Rd +++ b/man/SignaturePlotQC.Rd @@ -13,7 +13,7 @@ SignaturePlotQC( ncol = NA, pt.size = 1, assay = DefaultAssay(object), - slot = "data" + layer = "data" ) } \arguments{ @@ -33,7 +33,7 @@ SignaturePlotQC( \item{assay}{character(1). If some values to highlight are features rather than metadata columns, the assay from which they should be pulled in priority (Default: DefaultAssay(object)).} -\item{slot}{character(1). If some values to highlight are features rather than metadata columns, the slot from which they should be pulled (Default: "data").} +\item{layer}{character(1). If some values to highlight are features rather than metadata columns, the layer from which they should be pulled (Default: "data").} } \value{ Returns a ggplot/cowplot grid object. @@ -47,7 +47,7 @@ Can also be used in general as a combination of scatter plot and feature plot, a This is useful when making scRNA-seq from heterogeneous samples: for example immune cells are small and might be discarded as debris from much larger epithelial cancer cells if one is not aware of the differences in QC parameters occurring between various cell types. } \examples{ -# After MySeuratObject has been log-normalized in order to contain an RNA>data assay>slot and been augmented with a percent.mito metadata column: +# After MySeuratObject has been log-normalized in order to contain an RNA>data assay>layer and been augmented with a percent.mito metadata column: # SignatureList should be a list of character vectors, each containing a series of feature/gene names. MySeuratObject <- Impute(MySeuratObject) MySeuratObject <- ScoreSignatures(MySeuratObject,SignatureList)