... | ... |
@@ -1,18 +1,20 @@ |
1 |
-.myenv <- new.env(parent = emptyenv()) |
|
2 |
- |
|
3 | 1 |
#' Run GSVA analysis on a \linkS4class{SingleCellExperiment} object |
4 | 2 |
#' |
5 | 3 |
#' @param inSCE Input \linkS4class{SingleCellExperiment} object. |
6 | 4 |
#' @param useAssay Indicate which assay to use. The default is "logcounts" |
7 |
-#' @param geneSetCollectionName Character. The name of the gene set collection to use. |
|
8 |
-#' parameter. |
|
9 |
-#' @param resultNamePrefix Character. Prefix to the name the GSVA results which will be stored in the reducedDim slot of \code{inSCE}. The names of the output matrix will be \code{resultNamePrefix_Scores}. If this parameter is set to \code{NULL}, then "GSVA_geneSetCollectionName_" will be used. Default \code{NULL}. |
|
5 |
+#' @param geneSetCollectionName Character. The name of the gene set collection |
|
6 |
+#' to use. |
|
7 |
+#' @param resultNamePrefix Character. Prefix to the name the GSVA results |
|
8 |
+#' which will be stored in the reducedDim slot of \code{inSCE}. The names of the |
|
9 |
+#' output matrix will be \code{resultNamePrefix_Scores}. If this parameter is |
|
10 |
+#' set to \code{NULL}, then "GSVA_geneSetCollectionName_" will be used. Default |
|
11 |
+#' \code{NULL}. |
|
10 | 12 |
#' @param ... Parameters to pass to gsva() |
11 | 13 |
#' |
12 |
-#' @return A \link[SingleCellExperiment]{SingleCellExperiment} object with pathway activity scores from GSVA stored in \code{reducedDim} as \code{GSVA_geneSetCollectionName_Scores}. |
|
13 |
- |
|
14 |
+#' @return A \linkS4class{SingleCellExperiment} object with pathway activity |
|
15 |
+#' scores from GSVA stored in \code{reducedDim} as |
|
16 |
+#' \code{GSVA_geneSetCollectionName_Scores}. |
|
14 | 17 |
#' @export |
15 |
-#' |
|
16 | 18 |
#' @examples |
17 | 19 |
#' data(scExample, package = "singleCellTK") |
18 | 20 |
#' sce <- subsetSCECols(sce, colData = "type != 'EmptyDroplet'") |
... | ... |
@@ -23,36 +25,35 @@ |
23 | 25 |
#' |
24 | 26 |
#' sce <- importGeneSetsFromList(inSCE = sce,geneSetList = gs, |
25 | 27 |
#' by = "rownames") |
26 |
-#' sce <- runGSVA(inSCE = sce, geneSetCollectionName = "GeneSetCollection", useAssay = "logcounts") |
|
27 |
-#' |
|
28 |
-#' |
|
29 |
- |
|
28 |
+#' sce <- runGSVA(inSCE = sce, |
|
29 |
+#' geneSetCollectionName = "GeneSetCollection", |
|
30 |
+#' useAssay = "logcounts") |
|
30 | 31 |
runGSVA <- function(inSCE, useAssay = "logcounts", |
31 | 32 |
resultNamePrefix = NULL, geneSetCollectionName, ...){ |
32 |
- gsvaRes <- NULL |
|
33 |
- gene.Set <- .getGeneSetCollection(inSCE, geneSetCollectionName) |
|
33 |
+ gsvaRes <- NULL |
|
34 |
+ gene.Set <- .getGeneSetCollection(inSCE, geneSetCollectionName) |
|
34 | 35 |
|
36 |
+ message(date(), " ... Running GSVA") |
|
37 |
+ gsvaRes <- t(GSVA::gsva(as.matrix(expData(inSCE, useAssay)), |
|
38 |
+ gene.Set)) |
|
35 | 39 |
|
36 |
- gsvaRes <- t(GSVA::gsva(as.matrix(expData(inSCE, useAssay)), |
|
37 |
- gene.Set)) |
|
38 | 40 |
|
39 |
- |
|
40 |
- if(is.null(resultNamePrefix)) { |
|
41 |
- resultNamePrefix <- paste0("GSVA_", geneSetCollectionName, "_") |
|
42 |
- } |
|
43 |
- |
|
44 |
- SingleCellExperiment::reducedDim(inSCE, paste0(resultNamePrefix, "Scores")) <- gsvaRes |
|
45 |
- |
|
46 |
- if ("pathwayAnalysisResultNames" %in% names(S4Vectors::metadata(inSCE))) { |
|
47 |
- S4Vectors::metadata(inSCE)[["pathwayAnalysisResultNames"]] <- |
|
48 |
- c(S4Vectors::metadata(inSCE)[["pathwayAnalysisResultNames"]], |
|
49 |
- paste0(resultNamePrefix, "Scores")) |
|
50 |
- } else { |
|
51 |
- S4Vectors::metadata(inSCE)[["pathwayAnalysisResultNames"]] <- |
|
52 |
- c(paste0(resultNamePrefix, "Scores")) |
|
53 |
- } |
|
41 |
+ if(is.null(resultNamePrefix)) { |
|
42 |
+ resultNamePrefix <- paste0("GSVA_", geneSetCollectionName, "_") |
|
43 |
+ } |
|
54 | 44 |
|
45 |
+ SingleCellExperiment::reducedDim(inSCE, |
|
46 |
+ paste0(resultNamePrefix, |
|
47 |
+ "Scores")) <- gsvaRes |
|
55 | 48 |
|
49 |
+ if ("pathwayAnalysisResultNames" %in% names(S4Vectors::metadata(inSCE))) { |
|
50 |
+ S4Vectors::metadata(inSCE)[["pathwayAnalysisResultNames"]] <- |
|
51 |
+ c(S4Vectors::metadata(inSCE)[["pathwayAnalysisResultNames"]], |
|
52 |
+ paste0(resultNamePrefix, "Scores")) |
|
53 |
+ } else { |
|
54 |
+ S4Vectors::metadata(inSCE)[["pathwayAnalysisResultNames"]] <- |
|
55 |
+ c(paste0(resultNamePrefix, "Scores")) |
|
56 |
+ } |
|
57 |
+ |
|
56 | 58 |
return(inSCE) |
57 | 59 |
} |
58 |
- |
... | ... |
@@ -9,7 +9,7 @@ |
9 | 9 |
#' @param resultNamePrefix Character. Prefix to the name the GSVA results which will be stored in the reducedDim slot of \code{inSCE}. The names of the output matrix will be \code{resultNamePrefix_Scores}. If this parameter is set to \code{NULL}, then "GSVA_geneSetCollectionName_" will be used. Default \code{NULL}. |
10 | 10 |
#' @param ... Parameters to pass to gsva() |
11 | 11 |
#' |
12 |
-#' @return A \link[SingleCellExperiment]{SingleCellExperiment} object with pathway activity scores from GSVA stored in \code{reducedDim} as \code{GSVA_NameOfTheGeneset_Scores}. |
|
12 |
+#' @return A \link[SingleCellExperiment]{SingleCellExperiment} object with pathway activity scores from GSVA stored in \code{reducedDim} as \code{GSVA_geneSetCollectionName_Scores}. |
|
13 | 13 |
|
14 | 14 |
#' @export |
15 | 15 |
#' |
... | ... |
@@ -6,10 +6,10 @@ |
6 | 6 |
#' @param useAssay Indicate which assay to use. The default is "logcounts" |
7 | 7 |
#' @param geneSetCollectionName Character. The name of the gene set collection to use. |
8 | 8 |
#' parameter. |
9 |
-#' @param resultNamePrefix Character. Prefix to the name the VAM results which will be stored in the reducedDim slot of \code{inSCE}. The names of the output matrices will be \code{resultNamePrefix_Distance} and \code{resultNamePrefix_CDF}. If this parameter is set to \code{NULL}, then "VAM_geneSetCollectionName_" will be used. Default \code{NULL}. |
|
9 |
+#' @param resultNamePrefix Character. Prefix to the name the GSVA results which will be stored in the reducedDim slot of \code{inSCE}. The names of the output matrix will be \code{resultNamePrefix_Scores}. If this parameter is set to \code{NULL}, then "GSVA_geneSetCollectionName_" will be used. Default \code{NULL}. |
|
10 | 10 |
#' @param ... Parameters to pass to gsva() |
11 | 11 |
#' |
12 |
-#' @return A \link[SingleCellExperiment]{SingleCellExperiment} object with pathway activity scores from GSVA stored in \code{reducedDim} as \code{GSVA__NameOfTheGeneset_Scores}. |
|
12 |
+#' @return A \link[SingleCellExperiment]{SingleCellExperiment} object with pathway activity scores from GSVA stored in \code{reducedDim} as \code{GSVA_NameOfTheGeneset_Scores}. |
|
13 | 13 |
|
14 | 14 |
#' @export |
15 | 15 |
#' |
... | ... |
@@ -42,7 +42,15 @@ runGSVA <- function(inSCE, useAssay = "logcounts", |
42 | 42 |
} |
43 | 43 |
|
44 | 44 |
SingleCellExperiment::reducedDim(inSCE, paste0(resultNamePrefix, "Scores")) <- gsvaRes |
45 |
- |
|
45 |
+ |
|
46 |
+ if ("pathwayAnalysisResultNames" %in% names(S4Vectors::metadata(inSCE))) { |
|
47 |
+ S4Vectors::metadata(inSCE)[["pathwayAnalysisResultNames"]] <- |
|
48 |
+ c(S4Vectors::metadata(inSCE)[["pathwayAnalysisResultNames"]], |
|
49 |
+ paste0(resultNamePrefix, "Scores")) |
|
50 |
+ } else { |
|
51 |
+ S4Vectors::metadata(inSCE)[["pathwayAnalysisResultNames"]] <- |
|
52 |
+ c(paste0(resultNamePrefix, "Scores")) |
|
53 |
+ } |
|
46 | 54 |
|
47 | 55 |
|
48 | 56 |
return(inSCE) |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,50 @@ |
1 |
+.myenv <- new.env(parent = emptyenv()) |
|
2 |
+ |
|
3 |
+#' Run GSVA analysis on a \linkS4class{SingleCellExperiment} object |
|
4 |
+#' |
|
5 |
+#' @param inSCE Input \linkS4class{SingleCellExperiment} object. |
|
6 |
+#' @param useAssay Indicate which assay to use. The default is "logcounts" |
|
7 |
+#' @param geneSetCollectionName Character. The name of the gene set collection to use. |
|
8 |
+#' parameter. |
|
9 |
+#' @param resultNamePrefix Character. Prefix to the name the VAM results which will be stored in the reducedDim slot of \code{inSCE}. The names of the output matrices will be \code{resultNamePrefix_Distance} and \code{resultNamePrefix_CDF}. If this parameter is set to \code{NULL}, then "VAM_geneSetCollectionName_" will be used. Default \code{NULL}. |
|
10 |
+#' @param ... Parameters to pass to gsva() |
|
11 |
+#' |
|
12 |
+#' @return A \link[SingleCellExperiment]{SingleCellExperiment} object with pathway activity scores from GSVA stored in \code{reducedDim} as \code{GSVA__NameOfTheGeneset_Scores}. |
|
13 |
+ |
|
14 |
+#' @export |
|
15 |
+#' |
|
16 |
+#' @examples |
|
17 |
+#' data(scExample, package = "singleCellTK") |
|
18 |
+#' sce <- subsetSCECols(sce, colData = "type != 'EmptyDroplet'") |
|
19 |
+#' sce <- scaterlogNormCounts(sce, assayName = "logcounts") |
|
20 |
+#' gs1 <- rownames(sce)[seq(10)] |
|
21 |
+#' gs2 <- rownames(sce)[seq(11,20)] |
|
22 |
+#' gs <- list("geneset1" = gs1, "geneset2" = gs2) |
|
23 |
+#' |
|
24 |
+#' sce <- importGeneSetsFromList(inSCE = sce,geneSetList = gs, |
|
25 |
+#' by = "rownames") |
|
26 |
+#' sce <- runGSVA(inSCE = sce, geneSetCollectionName = "GeneSetCollection", useAssay = "logcounts") |
|
27 |
+#' |
|
28 |
+#' |
|
29 |
+ |
|
30 |
+runGSVA <- function(inSCE, useAssay = "logcounts", |
|
31 |
+ resultNamePrefix = NULL, geneSetCollectionName, ...){ |
|
32 |
+ gsvaRes <- NULL |
|
33 |
+ gene.Set <- .getGeneSetCollection(inSCE, geneSetCollectionName) |
|
34 |
+ |
|
35 |
+ |
|
36 |
+ gsvaRes <- t(GSVA::gsva(as.matrix(expData(inSCE, useAssay)), |
|
37 |
+ gene.Set)) |
|
38 |
+ |
|
39 |
+ |
|
40 |
+ if(is.null(resultNamePrefix)) { |
|
41 |
+ resultNamePrefix <- paste0("GSVA_", geneSetCollectionName, "_") |
|
42 |
+ } |
|
43 |
+ |
|
44 |
+ SingleCellExperiment::reducedDim(inSCE, paste0(resultNamePrefix, "Scores")) <- gsvaRes |
|
45 |
+ |
|
46 |
+ |
|
47 |
+ |
|
48 |
+ return(inSCE) |
|
49 |
+} |
|
50 |
+ |