... | ... |
@@ -10,7 +10,6 @@ export(computeZScore) |
10 | 10 |
export(convertGeneIDs) |
11 | 11 |
export(convertSCEToSeurat) |
12 | 12 |
export(convertSeuratToSCE) |
13 |
-export(createSCE) |
|
14 | 13 |
export(distinctColors) |
15 | 14 |
export(enrichRSCE) |
16 | 15 |
export(exportSCEtoAnnData) |
... | ... |
@@ -32,6 +31,7 @@ export(importCellRangerV2Sample) |
32 | 31 |
export(importCellRangerV3) |
33 | 32 |
export(importCellRangerV3Sample) |
34 | 33 |
export(importDropEst) |
34 |
+export(importFromFiles) |
|
35 | 35 |
export(importOptimus) |
36 | 36 |
export(importSEQC) |
37 | 37 |
export(importSTARsolo) |
... | ... |
@@ -14,21 +14,6 @@ |
14 | 14 |
#' |
15 | 15 |
#' @return gsvaSCE(): A data.frame of pathway activity scores from GSVA. |
16 | 16 |
#' @export |
17 |
-#' @examples |
|
18 |
-#' utils::data(maits, package = "MAST") |
|
19 |
-#' utils::data(c2BroadSets, package = "GSVAdata") |
|
20 |
-#' maitslogtpm <- t(maits$expressionmat) |
|
21 |
-#' genesToSubset <- rownames(maitslogtpm)[which(rownames(maitslogtpm) %in% |
|
22 |
-#' GSEABase::geneIds(c2BroadSets[["KEGG_PROTEASOME"]]))] |
|
23 |
-#' maitslogtpm <- maitslogtpm[rownames(maitslogtpm) %in% genesToSubset, ] |
|
24 |
-#' maitsfeatures <- maits$fdat[rownames(maits$fdat) %in% genesToSubset, ] |
|
25 |
-#' maitsSCE <- createSCE(assayFile = maitslogtpm, annotFile = maits$cdat, |
|
26 |
-#' featureFile = maitsfeatures, assayName = "logtpm", |
|
27 |
-#' inputDataFrames = TRUE, createLogCounts = FALSE) |
|
28 |
-#' rowData(maitsSCE)$testbiomarker <- rep(1, nrow(maitsSCE)) |
|
29 |
-#' res <- gsvaSCE(inSCE = maitsSCE, useAssay = "logtpm", |
|
30 |
-#' pathwaySource = "Manual Input", pathwayNames = "testbiomarker", |
|
31 |
-#' parallel.sz = 1) |
|
32 | 17 |
gsvaSCE <- function(inSCE, useAssay = "logcounts", pathwaySource, |
33 | 18 |
pathwayNames, ...){ |
34 | 19 |
if (pathwaySource == "Manual Input"){ |
... | ... |
@@ -74,25 +59,6 @@ gsvaSCE <- function(inSCE, useAssay = "logcounts", pathwaySource, |
74 | 59 |
#' @return gsvaPlot(): The requested plot of the GSVA results. |
75 | 60 |
#' |
76 | 61 |
#' @export |
77 |
-#' |
|
78 |
-#' @examples |
|
79 |
-#' #Create a small example to run |
|
80 |
-#' utils::data(maits, package = "MAST") |
|
81 |
-#' utils::data(c2BroadSets, package = "GSVAdata") |
|
82 |
-#' maitslogtpm <- t(maits$expressionmat) |
|
83 |
-#' genesToSubset <- rownames(maitslogtpm)[which(rownames(maitslogtpm) %in% |
|
84 |
-#' GSEABase::geneIds(c2BroadSets[["KEGG_PROTEASOME"]]))] |
|
85 |
-#' maitslogtpm <- maitslogtpm[rownames(maitslogtpm) %in% genesToSubset, ] |
|
86 |
-#' maitsfeatures <- maits$fdat[rownames(maits$fdat) %in% genesToSubset, ] |
|
87 |
-#' maitsSCE <- createSCE(assayFile = maitslogtpm, annotFile = maits$cdat, |
|
88 |
-#' featureFile = maitsfeatures, assayName = "logtpm", |
|
89 |
-#' inputDataFrames = TRUE, createLogCounts = FALSE) |
|
90 |
-#' rowData(maitsSCE)$testbiomarker <- rep(1, nrow(maitsSCE)) |
|
91 |
-#' res <- gsvaSCE(inSCE = maitsSCE, useAssay = "logtpm", |
|
92 |
-#' pathwaySource = "Manual Input", pathwayNames = "testbiomarker", |
|
93 |
-#' parallel.sz = 1) |
|
94 |
-#' gsvaPlot(inSCE = maitsSCE, gsvaData = res, |
|
95 |
-#' plotType = "Violin", condition = "condition") |
|
96 | 62 |
gsvaPlot <- function(inSCE, gsvaData, plotType, condition=NULL, |
97 | 63 |
show_column_names = TRUE, show_row_names = TRUE, |
98 | 64 |
text_size = 12){ |
... | ... |
@@ -219,7 +219,7 @@ alignSingleCellData <- function(inputfile1, inputfile2=NULL, indexPath, |
219 | 219 |
|
220 | 220 |
#createsceset from the count file, multiqcdata, and annotations if they exist |
221 | 221 |
# (validate the sample names are right) |
222 |
- scobject <- createSCE(assayFile = countframe, |
|
222 |
+ scobject <- importFromFiles(assayFile = countframe, |
|
223 | 223 |
annotFile = sampleAnnotations, |
224 | 224 |
featureFile = featureAnnotations, |
225 | 225 |
inputDataFrames = TRUE) |
226 | 226 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,83 @@ |
1 |
+#' Create a SingleCellExperiment object from files |
|
2 |
+#' |
|
3 |
+#' Creates a SingleCellExperiment object from a counts file in various formats. |
|
4 |
+#' and a file of annotation information, . |
|
5 |
+#' |
|
6 |
+#' @param assayFile The path to a file in .mtx, .txt, .csv, .tab, or .tsv format. |
|
7 |
+#' @param annotFile The path to a text file that contains columns of annotation |
|
8 |
+#' information for each sample in the assayFile. This file should have the same |
|
9 |
+#' number of rows as there are columns in the assayFile. If multiple samples are |
|
10 |
+#' represented in these files, this should be denoted by a column called \code{'sample'} |
|
11 |
+#' within the \code{annotFile}. |
|
12 |
+#' @param featureFile The path to a text file that contains columns of |
|
13 |
+#' annotation information for each gene in the count matrix. This file should |
|
14 |
+#' have the same genes in the same order as assayFile. This is optional. |
|
15 |
+#' @param assayName The name of the assay that you are uploading. The default |
|
16 |
+#' is "counts". |
|
17 |
+#' @param inputDataFrames If TRUE, assayFile and annotFile are read as data |
|
18 |
+#' frames instead of file paths. The default is FALSE. |
|
19 |
+#' @param class Character. The class of the expression matrix stored in the SCE |
|
20 |
+#' object. Can be one of "Matrix" (as returned by |
|
21 |
+#' \link[Matrix]{readMM} function), or "matrix" (as returned by |
|
22 |
+#' \link[base]{matrix} function). Default "Matrix". |
|
23 |
+#' @param delayedArray Boolean. Whether to read the expression matrix as |
|
24 |
+#' \link[DelayedArray]{DelayedArray} object or not. Default \code{TRUE}. |
|
25 |
+#' @return a SingleCellExperiment object |
|
26 |
+#' @export |
|
27 |
+importFromFiles <- function(assayFile, annotFile = NULL, featureFile = NULL, |
|
28 |
+ assayName = "counts", inputDataFrames = FALSE, |
|
29 |
+ class = c("Matrix", "matrix"), delayedArray = FALSE){ |
|
30 |
+ |
|
31 |
+ if (inputDataFrames){ |
|
32 |
+ countsin <- assayFile |
|
33 |
+ annotin <- annotFile |
|
34 |
+ featurein <- featureFile |
|
35 |
+ } else{ |
|
36 |
+ countsin <- readSingleCellMatrix(assayFile, class = class, delayedArray = delayedArray) |
|
37 |
+ if (!is.null(annotFile)){ |
|
38 |
+ annotin <- utils::read.table(annotFile, sep = "\t", header = TRUE, |
|
39 |
+ row.names = 1) |
|
40 |
+ } |
|
41 |
+ if (!is.null(featureFile)){ |
|
42 |
+ featurein <- utils::read.table(featureFile, sep = "\t", header = TRUE, |
|
43 |
+ row.names = 1) |
|
44 |
+ } |
|
45 |
+ } |
|
46 |
+ if (is.null(annotFile)){ |
|
47 |
+ annotin <- data.frame(row.names = colnames(countsin)) |
|
48 |
+ annotin$Sample <- rownames(annotin) |
|
49 |
+ annotin <- S4Vectors::DataFrame(annotin) |
|
50 |
+ } |
|
51 |
+ if (is.null(featureFile)){ |
|
52 |
+ featurein <- data.frame(Gene = rownames(countsin)) |
|
53 |
+ rownames(featurein) <- featurein$Gene |
|
54 |
+ featurein <- S4Vectors::DataFrame(featurein) |
|
55 |
+ } |
|
56 |
+ if (nrow(annotin) != ncol(countsin)){ |
|
57 |
+ stop("Different number of samples in input matrix and annotations: annot: ", |
|
58 |
+ nrow(annotin), ", counts: ", ncol(countsin)) |
|
59 |
+ } |
|
60 |
+ if (nrow(featurein) != nrow(countsin)){ |
|
61 |
+ stop("Different number of samples in input matrix and feature annotation", |
|
62 |
+ nrow(featurein), ", counts: ", nrow(countsin)) |
|
63 |
+ } |
|
64 |
+ if (any(rownames(annotin) != colnames(countsin))){ |
|
65 |
+ stop("Sample names in input matrix and annotation do not match!\nExample: ", |
|
66 |
+ rownames(annotin)[rownames(annotin) != colnames(countsin)][1], " vs. ", |
|
67 |
+ colnames(countsin)[rownames(annotin) != colnames(countsin)][1]) |
|
68 |
+ } |
|
69 |
+ if (any(rownames(featurein) != rownames(countsin))){ |
|
70 |
+ stop("Sample names in input matrix and feature annotation do not match!") |
|
71 |
+ } |
|
72 |
+ assaylist <- list() |
|
73 |
+ assaylist[[assayName]] <- methods::as(countsin, "dgCMatrix") |
|
74 |
+ newassay <- SingleCellExperiment::SingleCellExperiment(assays = assaylist, |
|
75 |
+ colData = annotin, |
|
76 |
+ rowData = featurein) |
|
77 |
+ |
|
78 |
+ if(is.null(newassay$sample)) { |
|
79 |
+ newassay$sample <- "sample" |
|
80 |
+ } |
|
81 |
+ |
|
82 |
+ return(newassay) |
|
83 |
+} |
... | ... |
@@ -2,8 +2,9 @@ |
2 | 2 |
#' |
3 | 3 |
#' Creates a table of summary metrics from an input SCtkExperiment. |
4 | 4 |
#' |
5 |
-#' @param inSCE Input SCtkExperiment object. |
|
6 |
-#' @param useAssay Indicate which assay to summarize. Default \code{"counts"}. |
|
5 |
+#' @param inSCE Input SingleCellExperiment object. |
|
6 |
+#' @param useAssay Indicate which assay to summarize. If \code{NULL}, then the first |
|
7 |
+#' assay in \code{inSCE} will be used. Default \code{NULL}. |
|
7 | 8 |
#' @param sampleVariableName Variable name in \code{colData} denoting which |
8 | 9 |
#' sample each cell belongs to. If \code{NULL}, all cells will be assumed |
9 | 10 |
#' to come from the same sample. Default \code{"sample"}. |
... | ... |
@@ -16,7 +17,11 @@ |
16 | 17 |
#' data("mouseBrainSubsetSCE") |
17 | 18 |
#' summarizeSCE(mouseBrainSubsetSCE, sample = NULL) |
18 | 19 |
#' |
19 |
-summarizeSCE <- function(inSCE, useAssay="counts", sampleVariableName = NULL){ |
|
20 |
+summarizeSCE <- function(inSCE, useAssay = NULL, sampleVariableName = NULL){ |
|
21 |
+ |
|
22 |
+ if(is.null(useAssay)) { |
|
23 |
+ useAssay <- names(assays(inSCE))[1] |
|
24 |
+ } |
|
20 | 25 |
|
21 | 26 |
if(is.null(sampleVariableName)) { |
22 | 27 |
sampleVariable <- rep("Sample", ncol(inSCE)) |
... | ... |
@@ -45,95 +50,6 @@ summarizeSCE <- function(inSCE, useAssay="counts", sampleVariableName = NULL){ |
45 | 50 |
return(df) |
46 | 51 |
} |
47 | 52 |
|
48 |
-#' Create a SCtkExperiment object |
|
49 |
-#' |
|
50 |
-#' From a file of counts and a file of annotation information, create a |
|
51 |
-#' SCtkExperiment object. |
|
52 |
-#' |
|
53 |
-#' @param assayFile The path to a text file that contains a header row of sample |
|
54 |
-#' names, and rows of raw counts per gene for those samples. |
|
55 |
-#' @param annotFile The path to a text file that contains columns of annotation |
|
56 |
-#' information for each sample in the assayFile. This file should have the same |
|
57 |
-#' number of rows as there are columns in the assayFile. |
|
58 |
-#' @param featureFile The path to a text file that contains columns of |
|
59 |
-#' annotation information for each gene in the count matrix. This file should |
|
60 |
-#' have the same genes in the same order as assayFile. This is optional. |
|
61 |
-#' @param assayName The name of the assay that you are uploading. The default |
|
62 |
-#' is "counts". |
|
63 |
-#' @param inputDataFrames If TRUE, assayFile and annotFile are read as data |
|
64 |
-#' frames instead of file paths. The default is FALSE. |
|
65 |
-#' @param createLogCounts If TRUE, create a log2(counts+1) normalized assay |
|
66 |
-#' and include it in the object. The default is TRUE |
|
67 |
-#' @return a SCtkExperiment object |
|
68 |
-#' @export |
|
69 |
-#' @examples |
|
70 |
-#' data("mouseBrainSubsetSCE") |
|
71 |
-#' counts_mat <- assay(mouseBrainSubsetSCE, "counts") |
|
72 |
-#' sample_annot <- colData(mouseBrainSubsetSCE) |
|
73 |
-#' row_annot <- rowData(mouseBrainSubsetSCE) |
|
74 |
-#' newSCE <- createSCE(assayFile = counts_mat, annotFile = sample_annot, |
|
75 |
-#' featureFile = row_annot, assayName = "counts", |
|
76 |
-#' inputDataFrames = TRUE, createLogCounts = TRUE) |
|
77 |
-createSCE <- function(assayFile=NULL, annotFile=NULL, featureFile=NULL, |
|
78 |
- assayName="counts", inputDataFrames=FALSE, |
|
79 |
- createLogCounts=TRUE){ |
|
80 |
- |
|
81 |
- if (is.null(assayFile)){ |
|
82 |
- stop("You must supply a count file.") |
|
83 |
- } |
|
84 |
- if (inputDataFrames){ |
|
85 |
- countsin <- assayFile |
|
86 |
- annotin <- annotFile |
|
87 |
- featurein <- featureFile |
|
88 |
- } else{ |
|
89 |
- countsin <- utils::read.table(assayFile, sep = "\t", header = TRUE, |
|
90 |
- row.names = 1) |
|
91 |
- if (!is.null(annotFile)){ |
|
92 |
- annotin <- utils::read.table(annotFile, sep = "\t", header = TRUE, |
|
93 |
- row.names = 1) |
|
94 |
- } |
|
95 |
- if (!is.null(featureFile)){ |
|
96 |
- featurein <- utils::read.table(featureFile, sep = "\t", header = TRUE, |
|
97 |
- row.names = 1) |
|
98 |
- } |
|
99 |
- } |
|
100 |
- if (is.null(annotFile)){ |
|
101 |
- annotin <- data.frame(row.names = colnames(countsin)) |
|
102 |
- annotin$Sample <- rownames(annotin) |
|
103 |
- annotin <- S4Vectors::DataFrame(annotin) |
|
104 |
- } |
|
105 |
- if (is.null(featureFile)){ |
|
106 |
- featurein <- data.frame(Gene = rownames(countsin)) |
|
107 |
- rownames(featurein) <- featurein$Gene |
|
108 |
- featurein <- S4Vectors::DataFrame(featurein) |
|
109 |
- } |
|
110 |
- if (nrow(annotin) != ncol(countsin)){ |
|
111 |
- stop("Different number of samples in input matrix and annotations: annot: ", |
|
112 |
- nrow(annotin), ", counts: ", ncol(countsin)) |
|
113 |
- } |
|
114 |
- if (nrow(featurein) != nrow(countsin)){ |
|
115 |
- stop("Different number of samples in input matrix and feature annotation", |
|
116 |
- nrow(featurein), ", counts: ", nrow(countsin)) |
|
117 |
- } |
|
118 |
- if (any(rownames(annotin) != colnames(countsin))){ |
|
119 |
- stop("Sample names in input matrix and annotation do not match!\nExample: ", |
|
120 |
- rownames(annotin)[rownames(annotin) != colnames(countsin)][1], " vs. ", |
|
121 |
- colnames(countsin)[rownames(annotin) != colnames(countsin)][1]) |
|
122 |
- } |
|
123 |
- if (any(rownames(featurein) != rownames(countsin))){ |
|
124 |
- stop("Sample names in input matrix and feature annotation do not match!") |
|
125 |
- } |
|
126 |
- assaylist <- list() |
|
127 |
- assaylist[[assayName]] <- as.matrix(countsin) |
|
128 |
- newassay <- SCtkExperiment(assays = assaylist, |
|
129 |
- colData = annotin, |
|
130 |
- rowData = featurein) |
|
131 |
- if (createLogCounts){ |
|
132 |
- SummarizedExperiment::assay(newassay, paste0("log", assayName)) <- |
|
133 |
- log2(SummarizedExperiment::assay(newassay, assayName) + 1) |
|
134 |
- } |
|
135 |
- return(newassay) |
|
136 |
-} |
|
137 | 53 |
|
138 | 54 |
#' Filter Genes and Samples from a Single Cell Object |
139 | 55 |
#' |
... | ... |
@@ -71,10 +71,11 @@ seuratNormalizeData <- function(inSCE, useAssay, normAssayName = "seuratNormData |
71 | 71 |
#' @return sceObject scaled sce object |
72 | 72 |
#' @export |
73 | 73 |
seuratScaleData <- function(inSCE, useAssay, scaledAssayName = "seuratScaledData", model = "linear", scale = TRUE, center = TRUE, scaleMax = 10) { |
74 |
- seuratObject <- Seurat::ScaleData(convertSCEToSeurat(inSCE, useAssay), features = rownames(inSCE), model.use = model, do.scale = scale, do.center = center, scale.max = as.double(scaleMax), verbose = FALSE) |
|
75 |
- inSCE <- .updateAssaySCE(inSCE, seuratObject, scaledAssayName, "scale.data") |
|
76 |
- inSCE <- .addSeuratToMetaDataSCE(inSCE, seuratObject) |
|
77 |
- return(inSCE) |
|
74 |
+ seuratObject <- convertSCEToSeurat(inSCE, useAssay) |
|
75 |
+ seuratObject <- Seurat::ScaleData(seuratObject, features = rownames(seuratObject), model.use = model, do.scale = scale, do.center = center, scale.max = as.double(scaleMax), verbose = FALSE) |
|
76 |
+ inSCE <- .updateAssaySCE(inSCE, seuratObject, scaledAssayName, "scale.data") |
|
77 |
+ inSCE <- .addSeuratToMetaDataSCE(inSCE, seuratObject) |
|
78 |
+ return(inSCE) |
|
78 | 79 |
} |
79 | 80 |
|
80 | 81 |
#' seuratFindHVG |
... | ... |
@@ -332,7 +333,7 @@ seuratComputeHeatmap <- function(inSCE, useAssay, useReduction = c("pca", "ica") |
332 | 333 |
if(is.null(dims)) { |
333 | 334 |
dims <- ncol(seuratObject@reductions[[useReduction]]) |
334 | 335 |
} |
335 |
- return(Seurat::DimHeatmap(seuratObject, dims = 1:dims, nfeatures = 30, reduction = useReduction, fast = fast, combine = combine, raster = raster)) |
|
336 |
+ return(Seurat::DimHeatmap(seuratObject, dims = 1:dims, nfeatures = nfeatures, reduction = useReduction, fast = fast, combine = combine, raster = raster)) |
|
336 | 337 |
} |
337 | 338 |
|
338 | 339 |
#' seuratHeatmapPlot |
... | ... |
@@ -755,55 +755,38 @@ shinyServer(function(input, output, session) { |
755 | 755 |
observeEvent(input$uploadData, { |
756 | 756 |
withBusyIndicatorServer("uploadData", { |
757 | 757 |
if (input$uploadChoice == "files"){ |
758 |
- vals$original <- createSCE(assayFile = input$countsfile$datapath, |
|
758 |
+ vals$original <- importFromFiles(assayFile = input$countsfile$datapath, |
|
759 | 759 |
annotFile = input$annotFile$datapath, |
760 | 760 |
featureFile = input$featureFile$datapath, |
761 | 761 |
assayName = input$inputAssayType) |
762 | 762 |
} else if (input$uploadChoice == "example"){ |
763 |
- if (input$selectExampleData == "mouseBrainSubset"){ |
|
764 |
- data(list = paste0(input$selectExampleData, "SCE")) |
|
765 |
- vals$original <- base::eval(parse(text = paste0(input$selectExampleData, "SCE"))) |
|
766 |
- } else if (input$selectExampleData == "maits"){ |
|
767 |
- data(maits, package = "MAST") |
|
768 |
- vals$original <- withConsoleRedirect(createSCE(assayFile = t(maits$expressionmat), |
|
769 |
- annotFile = maits$cdat, |
|
770 |
- featureFile = maits$fdat, |
|
771 |
- assayName = "logtpm", |
|
772 |
- inputDataFrames = TRUE, |
|
773 |
- createLogCounts = FALSE)) |
|
774 |
- rm(maits) |
|
775 |
- } else if (input$selectExampleData == "fluidigm_pollen_et_al") { |
|
776 |
- data(fluidigm, package = "scRNAseq") |
|
777 |
- tempsce <- as(fluidigm, "SingleCellExperiment") |
|
778 |
- vals$original <- as(tempsce, "SCtkExperiment") |
|
779 |
- rm(fluidigm, tempsce) |
|
763 |
+ if (input$selectExampleData == "fluidigm_pollen_et_al") { |
|
764 |
+ temp <- scRNAseq::ReprocessedFluidigmData() |
|
765 |
+ temp$sample <- paste0(colData(temp)$Biological_Condition, "_", colData(temp)$Coverage_Type) |
|
780 | 766 |
} else if (input$selectExampleData == "th2_mahata_et_al") { |
781 |
- data(th2, package = "scRNAseq") |
|
782 |
- tempsce <- as(th2, "SingleCellExperiment") |
|
783 |
- vals$original <- as(tempsce, "SCtkExperiment") |
|
784 |
- rm(th2, tempsce) |
|
767 |
+ temp <- scRNAseq::ReprocessedTh2Data() |
|
768 |
+ temp$sample <- "sample" |
|
785 | 769 |
} else if (input$selectExampleData == "allen_tasic_et_al") { |
786 |
- data(allen, package = "scRNAseq") |
|
787 |
- tempsce <- as(allen, "SingleCellExperiment") |
|
788 |
- vals$original <- as(tempsce, "SCtkExperiment") |
|
789 |
- rm(allen, tempsce) |
|
770 |
+ temp <- scRNAseq::ReprocessedAllenData() |
|
771 |
+ temp$sample <- paste0(colData(temp)$driver_1_s, "_", colData(temp)$dissection_s) |
|
790 | 772 |
} |
773 |
+ |
|
774 |
+ # Convert to sparseMatrix |
|
775 |
+ for(i in seq_along(names(assays(temp)))) { |
|
776 |
+ assay(temp, i) <- .convertToMatrix(assay(temp, i)) |
|
777 |
+ } |
|
778 |
+ |
|
779 |
+ vals$original <- temp |
|
780 |
+ rm(temp) |
|
781 |
+ |
|
791 | 782 |
} else if (input$uploadChoice == "rds") { |
792 | 783 |
importedrds <- readRDS(input$rdsFile$datapath) |
793 |
- if (methods::is(importedrds, "SummarizedExperiment")) { |
|
784 |
+ if (base::inherits(importedrds, "SummarizedExperiment")) { |
|
794 | 785 |
vals$original <- importedrds |
795 |
- seuratWorkflow$sce_rds_file <- input$rdsFile #for seurat workflow |
|
796 |
- } else { |
|
797 |
- vals$original <- NULL |
|
798 |
- } |
|
799 |
- } else if (input$uploadChoice == "rds_seurat") { |
|
800 |
- importedrds <- readRDS(input$rdsFileSeurat$datapath) |
|
801 |
- if (methods::is(importedrds, "Seurat")) { |
|
786 |
+ } else if (base::inherits(importedrds, "Seurat")) { |
|
802 | 787 |
vals$original <- convertSeuratToSCE(importedrds) |
803 |
- seuratWorkflow$sce_rds_file <- importedrds #for seurat workflow |
|
804 |
- } |
|
805 |
- else { |
|
806 |
- vals$original <- NULL |
|
788 |
+ } else { |
|
789 |
+ showNotification("The '.rds' file should contain a 'SingleCellExperiment' or 'Seurat' object.", type = "error") |
|
807 | 790 |
} |
808 | 791 |
} else if (input$uploadChoice == "directory") { |
809 | 792 |
if (input$algoChoice == "cellRanger2") { |
... | ... |
@@ -888,7 +871,6 @@ shinyServer(function(input, output, session) { |
888 | 871 |
} |
889 | 872 |
|
890 | 873 |
if (!is.null(vals$original)) { |
891 |
- # withConsoleRedirect({print(vals$original)}) |
|
892 | 874 |
vals$counts <- vals$original |
893 | 875 |
updateColDataNames() |
894 | 876 |
updateNumSamples() |
... | ... |
@@ -987,8 +969,7 @@ shinyServer(function(input, output, session) { |
987 | 969 |
} else { |
988 | 970 |
assaySelect <- input$filterAssaySelect |
989 | 971 |
} |
990 |
- singleCellTK::summarizeSCE(inSCE = vals$counts, |
|
991 |
- useAssay = "counts") |
|
972 |
+ singleCellTK::summarizeSCE(inSCE = vals$counts) |
|
992 | 973 |
}, striped = TRUE, border = TRUE, align = "c", spacing = "l") |
993 | 974 |
|
994 | 975 |
|
... | ... |
@@ -1238,7 +1219,11 @@ shinyServer(function(input, output, session) { |
1238 | 1219 |
req(vals$counts) |
1239 | 1220 |
withBusyIndicatorServer("normalizeAssay", { |
1240 | 1221 |
if (input$normalizeLibrarySelect == "seurat") { |
1241 |
- vals$counts <- seuratNormalizeData(vals$counts, input$normalizeAssaySelect, seuratWorkflow$geneNamesSeurat, input$normalizeAssayMethodSelect, as.numeric(input$normalizationScaleFactor)) |
|
1222 |
+ vals$counts <- seuratNormalizeData(inSCE = vals$counts, |
|
1223 |
+ useAssay = input$normalizeAssaySelect, |
|
1224 |
+ normAssayName = "seuratNormData", |
|
1225 |
+ normalizationMethod = input$normalizeAssayMethodSelect, |
|
1226 |
+ scaleFactor = as.numeric(input$normalizationScaleFactor)) |
|
1242 | 1227 |
updateAssayInputs() |
1243 | 1228 |
} |
1244 | 1229 |
else if (input$normalizeLibrarySelect == "cpm") { |
... | ... |
@@ -1464,46 +1449,48 @@ shinyServer(function(input, output, session) { |
1464 | 1449 |
} |
1465 | 1450 |
}) |
1466 | 1451 |
|
1467 |
- observe({ |
|
1468 |
- output$geneExpPlot <- renderPlot({ |
|
1469 |
- if (input$colorGeneBy == "Manual Input") { |
|
1470 |
- if (is.null(input$colorGenes)){ |
|
1471 |
- ggplot2::ggplot() + ggplot2::theme_bw() + |
|
1472 |
- ggplot2::theme(plot.background = ggplot2::element_rect(fill = "white")) + |
|
1473 |
- ggplot2::theme(panel.border = ggplot2::element_rect(colour = "white")) |
|
1474 |
- } else { |
|
1475 |
- if (input$axisNames == TRUE) { |
|
1476 |
- if (input$dimRedAxis1 == "" & input$dimRedAxis2 == "") { |
|
1477 |
- shinyalert::shinyalert("Error", text = "Enter axis names", type = "error") |
|
1478 |
- } else { |
|
1479 |
- comp1 <- input$dimRedAxis1 |
|
1480 |
- comp2 <- input$dimRedAxis2 |
|
1481 |
- } |
|
1482 |
- } else { |
|
1483 |
- comp1 <- NULL |
|
1484 |
- comp2 <- NULL |
|
1485 |
- } |
|
1486 |
- #shinyjs doesn't have any visibility functions so have used the following conditions |
|
1487 |
- if (any(grepl("PC*", colnames(reducedDim(vals$counts, input$usingReducedDims))))){ |
|
1488 |
- vals$pcX <- input$pcX |
|
1489 |
- vals$pcY <- input$pcY |
|
1490 |
- } else { |
|
1491 |
- vals$pcX <- NULL |
|
1492 |
- vals$pcY <- NULL |
|
1493 |
- } |
|
1494 |
- vals$dimRedPlot_geneExp <- singleCellTK::plotBiomarker(inSCE = vals$counts, |
|
1495 |
- gene = input$colorGenes, |
|
1496 |
- binary = input$colorBinary, |
|
1497 |
- shape = input$shapeBy, |
|
1498 |
- useAssay = input$dimRedAssaySelect, |
|
1499 |
- reducedDimName = input$usingReducedDims, |
|
1500 |
- comp1 = comp1, comp2 = comp2, |
|
1501 |
- x = vals$pcX, y = vals$pcY) |
|
1502 |
- vals$dimRedPlot_geneExp |
|
1503 |
- } |
|
1504 |
- } |
|
1505 |
- }) |
|
1506 |
- }) |
|
1452 |
+ # This code is commented out b/c it was causing a major lag whenever anything else was being |
|
1453 |
+ # updated. Maybe it needs to be changed to observeEvent? - Josh |
|
1454 |
+ # observe({ |
|
1455 |
+ # output$geneExpPlot <- renderPlot({ |
|
1456 |
+ # if (input$colorGeneBy == "Manual Input") { |
|
1457 |
+ # if (is.null(input$colorGenes)){ |
|
1458 |
+ # ggplot2::ggplot() + ggplot2::theme_bw() + |
|
1459 |
+ # ggplot2::theme(plot.background = ggplot2::element_rect(fill = "white")) + |
|
1460 |
+ # ggplot2::theme(panel.border = ggplot2::element_rect(colour = "white")) |
|
1461 |
+ # } else { |
|
1462 |
+ # if (input$axisNames == TRUE) { |
|
1463 |
+ # if (input$dimRedAxis1 == "" & input$dimRedAxis2 == "") { |
|
1464 |
+ # shinyalert::shinyalert("Error", text = "Enter axis names", type = "error") |
|
1465 |
+ # } else { |
|
1466 |
+ # comp1 <- input$dimRedAxis1 |
|
1467 |
+ # comp2 <- input$dimRedAxis2 |
|
1468 |
+ # } |
|
1469 |
+ # } else { |
|
1470 |
+ # comp1 <- NULL |
|
1471 |
+ # comp2 <- NULL |
|
1472 |
+ # } |
|
1473 |
+ # #shinyjs doesn't have any visibility functions so have used the following conditions |
|
1474 |
+ # if (any(grepl("PC*", colnames(reducedDim(vals$counts, input$usingReducedDims))))){ |
|
1475 |
+ # vals$pcX <- input$pcX |
|
1476 |
+ # vals$pcY <- input$pcY |
|
1477 |
+ # } else { |
|
1478 |
+ # vals$pcX <- NULL |
|
1479 |
+ # vals$pcY <- NULL |
|
1480 |
+ # } |
|
1481 |
+ # vals$dimRedPlot_geneExp <- singleCellTK::plotBiomarker(inSCE = vals$counts, |
|
1482 |
+ # gene = input$colorGenes, |
|
1483 |
+ # binary = input$colorBinary, |
|
1484 |
+ # shape = input$shapeBy, |
|
1485 |
+ # useAssay = input$dimRedAssaySelect, |
|
1486 |
+ # reducedDimName = input$usingReducedDims, |
|
1487 |
+ # comp1 = comp1, comp2 = comp2, |
|
1488 |
+ # x = vals$pcX, y = vals$pcY) |
|
1489 |
+ # vals$dimRedPlot_geneExp |
|
1490 |
+ # } |
|
1491 |
+ # } |
|
1492 |
+ # }) |
|
1493 |
+ # }) |
|
1507 | 1494 |
|
1508 | 1495 |
output$clusterPlot <- renderPlotly({ |
1509 | 1496 |
req(vals$dimRedPlot) |
... | ... |
@@ -2225,397 +2212,397 @@ shinyServer(function(input, output, session) { |
2225 | 2212 |
color_seqdiv <- rownames(color_table[which(color_table$category == "div" |
2226 | 2213 |
|color_table$category == "seq"),]) |
2227 | 2214 |
|
2228 |
- #-+-+-+-+-+-For Input Observe############## |
|
2229 |
- observe({ |
|
2230 |
- # is there an error or not |
|
2231 |
- if (is.null(vals$counts)) { |
|
2232 |
- # shinyalert::shinyalert("Error!", "Upload data first.", type = "error") |
|
2233 |
- } else { |
|
2234 |
- #colorbrewer_list <- rownames(RColorBrewer::brewer.pal.info) |
|
2235 |
- #color_table <- RColorBrewer::brewer.pal.info %>% data.frame() |
|
2236 |
- #color_seqdiv <- rownames(color_table[which(color_table$category == "div" |
|
2237 |
- # |color_table$category == "seq"),]) |
|
2238 |
- #from sce |
|
2239 |
- cell_list <- BiocGenerics::colnames(vals$counts) |
|
2240 |
- gene_list <- BiocGenerics::rownames(vals$counts) |
|
2241 |
- #from assays |
|
2242 |
- method_list <- names(assays(vals$counts)) |
|
2243 |
- #from reduced |
|
2244 |
- approach_list <- names(reducedDims(vals$counts)) |
|
2245 |
- #from colData |
|
2246 |
- annotation_list <- names(colData(vals$counts)) |
|
2247 |
- |
|
2248 |
- updateSelectInput(session, "QuickAccess", |
|
2249 |
- choices = c("",approach_list,"Custom")) |
|
2250 |
- updateSelectInput(session, "ApproachSelect_Xaxis", |
|
2251 |
- choices = c(approach_list)) |
|
2252 |
- updateSelectInput(session, "AdvancedMethodSelect_Xaxis", |
|
2253 |
- choices = c(method_list)) |
|
2254 |
- updateSelectInput(session, "GeneSelect_Assays_Xaxis", |
|
2255 |
- choices = c(gene_list)) |
|
2256 |
- updateSelectInput(session, "AnnotationSelect_Xaxis", |
|
2257 |
- choices = c(annotation_list)) |
|
2258 |
- updateSelectInput(session, "ApproachSelect_Yaxis", |
|
2259 |
- choices = c(approach_list)) |
|
2260 |
- updateSelectInput(session, "AdvancedMethodSelect_Yaxis", |
|
2261 |
- choices = c(method_list)) |
|
2262 |
- updateSelectInput(session, "GeneSelect_Assays_Yaxis", |
|
2263 |
- choices = c(gene_list)) |
|
2264 |
- updateSelectInput(session, "AnnotationSelect_Yaxis", |
|
2265 |
- choices = c(annotation_list)) |
|
2266 |
- updateSelectInput(session, "ApproachSelect_Colorby", |
|
2267 |
- choices = c(approach_list)) |
|
2268 |
- updateSelectInput(session, "AdvancedMethodSelect_Colorby", |
|
2269 |
- choices = c(method_list)) |
|
2270 |
- updateSelectInput(session, "GeneSelect_Assays_Colorby", |
|
2271 |
- choices = c(gene_list)) |
|
2272 |
- updateSelectInput(session, "AnnotationSelect_Colorby", |
|
2273 |
- choices = c(annotation_list)) |
|
2274 |
- updateSelectizeInput(session, "adjustgroupby", label = NULL, choices = c("None", annotation_list)) |
|
2275 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", |
|
2276 |
- choices = c("RdYlBu",color_seqdiv)) |
|
2277 |
- } |
|
2278 |
- }) |
|
2279 |
- |
|
2280 |
- #-+-+-+-+-+-For Advanced Input Observe############## |
|
2281 |
- ###ApproachSelect to DimensionSelect X-Axis |
|
2282 |
- observe({ |
|
2283 |
- if (!is.null(vals$counts)){ |
|
2284 |
- len <- length(SingleCellExperiment::reducedDims(vals$counts)) |
|
2285 |
- if (!is.null(input$ApproachSelect_Xaxis) & len > 0){ |
|
2286 |
- Df <- data.frame(SingleCellExperiment::reducedDim(vals$counts,input$ApproachSelect_Xaxis)) |
|
2287 |
- xs <- colnames(Df) |
|
2288 |
- updateSelectInput(session, "ColumnSelect_Xaxis", choices = c(xs)) |
|
2289 |
- rm(Df) |
|
2290 |
- } |
|
2291 |
- } |
|
2292 |
- }) |
|
2293 |
- ###ApproachSelect to DimensionSelect Y-Axis |
|
2294 |
- observe({ |
|
2295 |
- if (!is.null(vals$counts)){ |
|
2296 |
- len <- length(SingleCellExperiment::reducedDims(vals$counts)) |
|
2297 |
- if (!is.null(input$ApproachSelect_Yaxis) & len > 0){ |
|
2298 |
- Df2 <- data.frame(SingleCellExperiment::reducedDim(vals$counts,input$ApproachSelect_Yaxis)) |
|
2299 |
- xs2 <- colnames(Df2) |
|
2300 |
- xs2 <- sort(xs2, decreasing = TRUE) |
|
2301 |
- updateSelectInput(session, "ColumnSelect_Yaxis", choices = c(xs2)) |
|
2302 |
- rm(Df2) |
|
2303 |
- } |
|
2304 |
- } |
|
2305 |
- }) |
|
2306 |
- ###ApproachSelect to DimensionSelect Colorby |
|
2307 |
- observe({ |
|
2308 |
- if (!is.null(vals$counts)){ |
|
2309 |
- len <- length(SingleCellExperiment::reducedDims(vals$counts)) |
|
2310 |
- if (!is.null(input$ApproachSelect_Colorby) & len > 0){ |
|
2311 |
- Df3 <- data.frame(SingleCellExperiment::reducedDim(vals$counts,input$ApproachSelect_Colorby)) |
|
2312 |
- xs3 <- colnames(Df3) |
|
2313 |
- updateSelectInput(session, "ColumnSelect_Colorby", choices = c(xs3)) |
|
2314 |
- rm(Df3) |
|
2315 |
- } |
|
2316 |
- } |
|
2317 |
- }) |
|
2318 |
- |
|
2319 |
- #-+-+-+-+-+-Observe Group by################################################### |
|
2320 |
- ###Observe Radio Button Select Value Type |
|
2321 |
- observe({ |
|
2322 |
- if (!is.null(vals$counts)){ |
|
2323 |
- if (input$adjustgroupby != 'None'){ |
|
2324 |
- #Integer,level>25# |
|
2325 |
- if(is.integer(colData(vals$counts)@listData[[input$adjustgroupby]]) |
|
2326 |
- & length(levels(as.factor(colData(vals$counts)@listData[[input$adjustgroupby]])))>25){ |
|
2327 |
- updateRadioButtons(session, "SelectValueType", "Categorical or Continuous", |
|
2328 |
- choices = c("Categorical", "Continuous"), |
|
2329 |
- selected = "Continuous") |
|
2330 |
- shinyjs::delay(5,shinyjs::disable("SelectValueType")) |
|
2331 |
- #Integer,level<25# |
|
2332 |
- }else if(is.integer(colData(vals$counts)@listData[[input$adjustgroupby]]) |
|
2333 |
- & length(levels(as.factor(colData(vals$counts)@listData[[input$adjustgroupby]])))<=25){ |
|
2334 |
- updateRadioButtons(session, "SelectValueType", "Categorical or Continuous", |
|
2335 |
- choices = c("Categorical", "Continuous"), |
|
2336 |
- selected = "Categorical") |
|
2337 |
- shinyjs::enable("SelectValueType") |
|
2338 |
- #Numeric,noninteger# |
|
2339 |
- }else if(is.numeric(colData(vals$counts)@listData[[input$adjustgroupby]])){ |
|
2340 |
- updateRadioButtons(session, "SelectValueType", "Categorical or Continuous", |
|
2341 |
- choices = c("Categorical", "Continuous"), |
|
2342 |
- selected = "Continuous") |
|
2343 |
- shinyjs::delay(5,shinyjs::disable("SelectValueType")) |
|
2344 |
- #Categorical# |
|
2345 |
- }else{ |
|
2346 |
- updateRadioButtons(session, "SelectValueType", "Categorical or Continuous", |
|
2347 |
- choices = c("Categorical", "Continuous"), |
|
2348 |
- selected = "Categorical") |
|
2349 |
- shinyjs::delay(5,shinyjs::disable("SelectValueType"))} |
|
2350 |
- } |
|
2351 |
- } |
|
2352 |
- })#observe_end |
|
2353 |
- |
|
2354 |
- ###Observe Check Box Check Binning & Text Input Number of Bins: |
|
2355 |
- |
|
2356 |
- observe({ |
|
2357 |
- if (!is.null(vals$counts)){ |
|
2358 |
- if (input$adjustgroupby != 'None'){ |
|
2359 |
- #Integer,level>25# |
|
2360 |
- if(is.integer(colData(vals$counts)@listData[[input$adjustgroupby]]) |
|
2361 |
- &length(levels(as.factor(colData(vals$counts)@listData[[input$adjustgroupby]])))>25){ |
|
2362 |
- updateCheckboxInput(session,"checkbinning","Perform Binning", value = TRUE) |
|
2363 |
- shinyjs::delay(5,shinyjs::disable("checkbinning")) |
|
2364 |
- shinyjs::enable("adjustbinning") |
|
2365 |
- #Integer,level<25,continuous |
|
2366 |
- }else if(is.integer(colData(vals$counts)@listData[[input$adjustgroupby]]) |
|
2367 |
- &length(levels(as.factor(colData(vals$counts)@listData[[input$adjustgroupby]])))<=25 |
|
2368 |
- &input$SelectValueType == "Continuous"){ |
|
2369 |
- updateCheckboxInput(session,"checkbinning","Perform Binning", value = TRUE) |
|
2370 |
- shinyjs::delay(5,shinyjs::disable("checkbinning")) |
|
2371 |
- shinyjs::enable("adjustbinning") |
|
2372 |
- #Integer,level<25,Categorical |
|
2373 |
- }else if(is.integer(colData(vals$counts)@listData[[input$adjustgroupby]]) |
|
2374 |
- &length(levels(as.factor(colData(vals$counts)@listData[[input$adjustgroupby]])))<=25 |
|
2375 |
- &input$SelectValueType == "Categorical"){ |
|
2376 |
- updateCheckboxInput(session,"checkbinning","Perform Binning", value = FALSE) |
|
2377 |
- shinyjs::delay(5,shinyjs::disable("checkbinning")) |
|
2378 |
- shinyjs::disable("adjustbinning") |
|
2379 |
- #Numeric,noninteger |
|
2380 |
- }else if(is.numeric(colData(vals$counts)@listData[[input$adjustgroupby]])){ |
|
2381 |
- updateCheckboxInput(session,"checkbinning","Perform Binning", value = TRUE) |
|
2382 |
- shinyjs::delay(5,shinyjs::disable("checkbinning")) |
|
2383 |
- shinyjs::enable("adjustbinning") |
|
2384 |
- #Categorical |
|
2385 |
- }else{updateCheckboxInput(session,"checkbinning","Perform Binning", value = FALSE) |
|
2386 |
- shinyjs::delay(5,shinyjs::disable("checkbinning")) |
|
2387 |
- shinyjs::disable("adjustbinning") |
|
2388 |
- } |
|
2389 |
- } |
|
2390 |
- } |
|
2391 |
- })#observe_end |
|
2392 |
- |
|
2393 |
- #-+-+-+-+-+-Observe Color bye################################################### |
|
2394 |
- ###Observe Radio Button Select Value Type |
|
2395 |
- observe({ |
|
2396 |
- if (!is.null(vals$counts)){ |
|
2397 |
- if (input$TypeSelect_Colorby != 'Pick a Color'){ |
|
2398 |
- ###If Cell Annotation############################################################### |
|
2399 |
- if(input$TypeSelect_Colorby == 'Cell Annotation'){ |
|
2400 |
- ###If Cell Annotation numeric |
|
2401 |
- if(!is.numeric(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]])){ |
|
2402 |
- updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2403 |
- choices = c("Categorical", "Continuous"), |
|
2404 |
- selected = "Categorical") |
|
2405 |
- shinyjs::delay(5,shinyjs::disable("SelectColorType")) |
|
2406 |
- |
|
2407 |
- |
|
2408 |
- }else if(is.integer(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]]) |
|
2409 |
- &length(levels(as.factor(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]])))<=25){ |
|
2410 |
- updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2411 |
- choices = c("Categorical", "Continuous"), |
|
2412 |
- selected = "Categorical") |
|
2413 |
- shinyjs::enable("SelectColorType") |
|
2414 |
- |
|
2415 |
- }else{updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2416 |
- choices = c("Categorical", "Continuous"), |
|
2417 |
- selected = "Continuous") |
|
2418 |
- shinyjs::delay(5,shinyjs::disable("SelectColorType"))} |
|
2419 |
- |
|
2420 |
- ###If ReducedData########################################################## |
|
2421 |
- }else if(input$TypeSelect_Colorby == 'Reduced Dimensions'){ |
|
2422 |
- Dfcolor <- data.frame(reducedDims(vals$counts)@listData[[input$ApproachSelect_Colorby]]) |
|
2423 |
- if(input$ColumnSelect_Colorby %in% colnames(Dfcolor)){ |
|
2424 |
- Dfcolor <- Dfcolor[which(colnames(Dfcolor) == input$ColumnSelect_Colorby)] |
|
2425 |
- ###If ReducedData numeric |
|
2426 |
- |
|
2427 |
- if(!is.numeric(Dfcolor[,1])){ |
|
2428 |
- updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2429 |
- choices = c("Categorical", "Continuous"), |
|
2430 |
- selected = "Categorical") |
|
2431 |
- shinyjs::delay(5,shinyjs::disable("SelectColorType")) |
|
2432 |
- |
|
2433 |
- |
|
2434 |
- }else if(is.integer(Dfcolor[,1]) |
|
2435 |
- &length(levels(as.factor(Dfcolor[,1])))<=25){ |
|
2436 |
- updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2437 |
- choices = c("Categorical", "Continuous"), |
|
2438 |
- selected = "Categorical") |
|
2439 |
- shinyjs::enable("SelectColorType") |
|
2440 |
- |
|
2441 |
- }else{updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2442 |
- choices = c("Categorical", "Continuous"), |
|
2443 |
- selected = "Continuous") |
|
2444 |
- shinyjs::delay(5,shinyjs::disable("SelectColorType"))} |
|
2445 |
- } |
|
2446 |
- ###If Expression Assays########################################################### |
|
2447 |
- }else{Dfassay <- assay(vals$counts, input$AdvancedMethodSelect_Colorby) |
|
2448 |
- if(input$GeneSelect_Assays_Colorby %in% rownames(Dfassay)){ |
|
2449 |
- Dfassay <- data.frame(Dfassay[which(rownames(Dfassay)== input$GeneSelect_Assays_Colorby),]) |
|
2450 |
- |
|
2451 |
- if(!is.numeric(Dfassay[,1])){ |
|
2452 |
- updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2453 |
- choices = c("Categorical", "Continuous"), |
|
2454 |
- selected = "Categorical") |
|
2455 |
- shinyjs::delay(5,shinyjs::disable("SelectColorType")) |
|
2456 |
- |
|
2457 |
- |
|
2458 |
- }else if(is.integer(Dfassay[,1]) |
|
2459 |
- &length(levels(as.factor(Dfassay[,1])))<=25){ |
|
2460 |
- updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2461 |
- choices = c("Categorical", "Continuous"), |
|
2462 |
- selected = "Categorical") |
|
2463 |
- shinyjs::enable("SelectColorType") |
|
2464 |
- |
|
2465 |
- }else{updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2466 |
- choices = c("Categorical", "Continuous"), |
|
2467 |
- selected = "Continuous") |
|
2468 |
- shinyjs::delay(5,shinyjs::disable("SelectColorType"))} |
|
2469 |
- } |
|
2470 |
- } |
|
2471 |
- } |
|
2472 |
- } |
|
2473 |
- })###observe_end |
|
2474 |
- |
|
2475 |
- ###Observe Check Box Check Binning & Text Input Number of Bins: |
|
2476 |
- observe({ |
|
2477 |
- if (!is.null(vals$counts)){ |
|
2478 |
- ###If Cell Annotation############################################################### |
|
2479 |
- if(input$TypeSelect_Colorby != 'Pick a Color'){ |
|
2480 |
- |
|
2481 |
- if(input$TypeSelect_Colorby == 'Cell Annotation'){ |
|
2482 |
- if(!is.numeric(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]])){ |
|
2483 |
- updateCheckboxInput(session,"checkColorbinning","Perform Binning", value = FALSE) |
|
2484 |
- shinyjs::delay(5,shinyjs::disable("checkColorbinning")) |
|
2485 |
- shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2486 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda")) |
|
2487 |
- |
|
2488 |
- }else if(is.integer(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]]) |
|
2489 |
- &length(levels(as.factor(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]])))<=25 |
|
2490 |
- &input$SelectColorType == 'Categorical'){ |
|
2491 |
- updateCheckboxInput(session,"checkColorbinning","Perform Binning", value = FALSE) |
|
2492 |
- shinyjs::delay(5,shinyjs::disable("checkColorbinning")) |
|
2493 |
- shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2494 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda")) |
|
2495 |
- |
|
2496 |
- }else if(is.integer(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]]) |
|
2497 |
- &length(levels(as.factor(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]])))<=25 |
|
2498 |
- &input$SelectColorType == 'Continuous'){ |
|
2499 |
- |
|
2500 |
- shinyjs::enable("checkColorbinning") |
|
2501 |
- if(input$checkColorbinning == TRUE){ |
|
2502 |
- shinyjs::enable("adjustColorbinning") |
|
2503 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda"))} |
|
2504 |
- |
|
2505 |
- else{ |
|
2506 |
- shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2507 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("RdYlBu",color_seqdiv))} |
|
2508 |
- |
|
2509 |
- }else{ |
|
2510 |
- |
|
2511 |
- shinyjs::enable("checkColorbinning") |
|
2512 |
- if(input$checkColorbinning == TRUE){ |
|
2513 |
- shinyjs::enable("adjustColorbinning") |
|
2514 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda"))} |
|
2515 |
- |
|
2516 |
- else{ |
|
2517 |
- shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2518 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("RdYlBu",color_seqdiv))} |
|
2519 |
- } |
|
2520 |
- |
|
2521 |
- |
|
2522 |
- ###If Reduce Dimensions############################################################## |
|
2523 |
- }else if(input$TypeSelect_Colorby == 'Reduced Dimensions'){ |
|
2524 |
- Dfcolor <- data.frame(reducedDims(vals$counts)@listData[[input$ApproachSelect_Colorby]]) |
|
2525 |
- if(input$ColumnSelect_Colorby %in% colnames(Dfcolor)){ |
|
2526 |
- Dfcolor <- Dfcolor[which(colnames(Dfcolor) == input$ColumnSelect_Colorby)] |
|
2527 |
- |
|
2528 |
- if(!is.numeric(Dfcolor[,1])){ |
|
2529 |
- updateCheckboxInput(session,"checkColorbinning","Perform Binning", value = FALSE) |
|
2530 |
- shinyjs::delay(5,shinyjs::disable("checkColorbinning")) |
|
2531 |
- shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2532 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda")) |
|
2533 |
- |
|
2534 |
- }else if(is.integer(Dfcolor[,1]) |
|
2535 |
- &length(levels(as.factor(Dfcolor[,1])))<=25 |
|
2536 |
- &input$SelectColorType == 'Categorical'){ |
|
2537 |
- updateCheckboxInput(session,"checkColorbinning","Perform Binning", value = FALSE) |
|
2538 |
- shinyjs::delay(5,shinyjs::disable("checkColorbinning")) |
|
2539 |
- shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2540 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda")) |
|
2541 |
- |
|
2542 |
- }else if(is.integer(Dfcolor[,1]) |
|
2543 |
- &length(levels(as.factor(Dfcolor[,1])))<=25 |
|
2544 |
- &input$SelectColorType == 'Continuous'){ |
|
2545 |
- |
|
2546 |
- shinyjs::enable("checkColorbinning") |
|
2547 |
- if(input$checkColorbinning == TRUE){ |
|
2548 |
- shinyjs::enable("adjustColorbinning") |
|
2549 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda"))} |
|
2550 |
- |
|
2551 |
- else{ |
|
2552 |
- shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2553 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("RdYlBu",color_seqdiv))} |
|
2554 |
- |
|
2555 |
- }else{ |
|
2556 |
- |
|
2557 |
- shinyjs::enable("checkColorbinning") |
|
2558 |
- if(input$checkColorbinning == TRUE){ |
|
2559 |
- shinyjs::enable("adjustColorbinning") |
|
2560 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda"))} |
|
2561 |
- |
|
2562 |
- else{ |
|
2563 |
- shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2564 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("RdYlBu",color_seqdiv))} |
|
2565 |
- } |
|
2566 |
- } |
|
2567 |
- |
|
2568 |
- |
|
2569 |
- ###If Expression Assays########################################################## |
|
2570 |
- }else{Dfassay <- assay(vals$counts, input$AdvancedMethodSelect_Colorby) |
|
2571 |
- if(input$GeneSelect_Assays_Colorby %in% rownames(Dfassay)){ |
|
2572 |
- Dfassay <- data.frame(Dfassay[which(rownames(Dfassay)== input$GeneSelect_Assays_Colorby),]) |
|
2573 |
- |
|
2574 |
- if(!is.numeric(Dfassay[,1])){ |
|
2575 |
- updateCheckboxInput(session,"checkColorbinning","Perform Binning", value = FALSE) |
|
2576 |
- shinyjs::delay(5,shinyjs::disable("checkColorbinning")) |
|
2577 |
- shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2578 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda")) |
|
2579 |
- |
|
2580 |
- }else if(is.integer(Dfassay[,1]) |
|
2581 |
- &length(levels(as.factor(Dfassay[,1])))<=25 |
|
2582 |
- &input$SelectColorType == 'Categorical'){ |
|
2583 |
- updateCheckboxInput(session,"checkColorbinning","Perform Binning", value = FALSE) |
|
2584 |
- shinyjs::delay(5,shinyjs::disable("checkColorbinning")) |
|
2585 |
- shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2586 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda")) |
|
2587 |
- |
|
2588 |
- }else if(is.integer(Dfassay[,1]) |
|
2589 |
- &length(levels(as.factor(Dfassay[,1])))<=25 |
|
2590 |
- &input$SelectColorType == 'Continuous'){ |
|
2591 |
- |
|
2592 |
- shinyjs::enable("checkColorbinning") |
|
2593 |
- if(input$checkColorbinning == TRUE){ |
|
2594 |
- shinyjs::enable("adjustColorbinning") |
|
2595 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda"))} |
|
2596 |
- |
|
2597 |
- else{ |
|
2598 |
- shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2599 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("RdYlBu",color_seqdiv))} |
|
2600 |
- |
|
2601 |
- }else{ |
|
2602 |
- |
|
2603 |
- shinyjs::enable("checkColorbinning") |
|
2604 |
- if(input$checkColorbinning == TRUE){ |
|
2605 |
- shinyjs::enable("adjustColorbinning") |
|
2606 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda"))} |
|
2607 |
- |
|
2608 |
- else{ |
|
2609 |
- shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2610 |
- updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("RdYlBu",color_seqdiv)) |
|
2611 |
- } |
|
2612 |
- } |
|
2613 |
- } |
|
2614 |
- }#Dfassay_end |
|
2615 |
- }#ifnot_end |
|
2616 |
- } |
|
2617 |
- })###observe_end |
|
2618 |
- |
|
2215 |
+ # #-+-+-+-+-+-For Input Observe############## |
|
2216 |
+ # observe({ |
|
2217 |
+ # # is there an error or not |
|
2218 |
+ # if (is.null(vals$counts)) { |
|
2219 |
+ # # shinyalert::shinyalert("Error!", "Upload data first.", type = "error") |
|
2220 |
+ # } else { |
|
2221 |
+ # #colorbrewer_list <- rownames(RColorBrewer::brewer.pal.info) |
|
2222 |
+ # #color_table <- RColorBrewer::brewer.pal.info %>% data.frame() |
|
2223 |
+ # #color_seqdiv <- rownames(color_table[which(color_table$category == "div" |
|
2224 |
+ # # |color_table$category == "seq"),]) |
|
2225 |
+ # #from sce |
|
2226 |
+ # cell_list <- BiocGenerics::colnames(vals$counts) |
|
2227 |
+ # gene_list <- BiocGenerics::rownames(vals$counts) |
|
2228 |
+ # #from assays |
|
2229 |
+ # method_list <- names(assays(vals$counts)) |
|
2230 |
+ # #from reduced |
|
2231 |
+ # approach_list <- names(reducedDims(vals$counts)) |
|
2232 |
+ # #from colData |
|
2233 |
+ # annotation_list <- names(colData(vals$counts)) |
|
2234 |
+ # |
|
2235 |
+ # updateSelectInput(session, "QuickAccess", |
|
2236 |
+ # choices = c("",approach_list,"Custom")) |
|
2237 |
+ # updateSelectInput(session, "ApproachSelect_Xaxis", |
|
2238 |
+ # choices = c(approach_list)) |
|
2239 |
+ # updateSelectInput(session, "AdvancedMethodSelect_Xaxis", |
|
2240 |
+ # choices = c(method_list)) |
|
2241 |
+ # updateSelectInput(session, "GeneSelect_Assays_Xaxis", |
|
2242 |
+ # choices = c(gene_list)) |
|
2243 |
+ # updateSelectInput(session, "AnnotationSelect_Xaxis", |
|
2244 |
+ # choices = c(annotation_list)) |
|
2245 |
+ # updateSelectInput(session, "ApproachSelect_Yaxis", |
|
2246 |
+ # choices = c(approach_list)) |
|
2247 |
+ # updateSelectInput(session, "AdvancedMethodSelect_Yaxis", |
|
2248 |
+ # choices = c(method_list)) |
|
2249 |
+ # updateSelectInput(session, "GeneSelect_Assays_Yaxis", |
|
2250 |
+ # choices = c(gene_list)) |
|
2251 |
+ # updateSelectInput(session, "AnnotationSelect_Yaxis", |
|
2252 |
+ # choices = c(annotation_list)) |
|
2253 |
+ # updateSelectInput(session, "ApproachSelect_Colorby", |
|
2254 |
+ # choices = c(approach_list)) |
|
2255 |
+ # updateSelectInput(session, "AdvancedMethodSelect_Colorby", |
|
2256 |
+ # choices = c(method_list)) |
|
2257 |
+ # updateSelectInput(session, "GeneSelect_Assays_Colorby", |
|
2258 |
+ # choices = c(gene_list)) |
|
2259 |
+ # updateSelectInput(session, "AnnotationSelect_Colorby", |
|
2260 |
+ # choices = c(annotation_list)) |
|
2261 |
+ # updateSelectizeInput(session, "adjustgroupby", label = NULL, choices = c("None", annotation_list)) |
|
2262 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", |
|
2263 |
+ # choices = c("RdYlBu",color_seqdiv)) |
|
2264 |
+ # } |
|
2265 |
+ # }) |
|
2266 |
+ # |
|
2267 |
+ # #-+-+-+-+-+-For Advanced Input Observe############## |
|
2268 |
+ # ###ApproachSelect to DimensionSelect X-Axis |
|
2269 |
+ # observe({ |
|
2270 |
+ # if (!is.null(vals$counts)){ |
|
2271 |
+ # len <- length(SingleCellExperiment::reducedDims(vals$counts)) |
|
2272 |
+ # if (!is.null(input$ApproachSelect_Xaxis) & len > 0){ |
|
2273 |
+ # Df <- data.frame(SingleCellExperiment::reducedDim(vals$counts,input$ApproachSelect_Xaxis)) |
|
2274 |
+ # xs <- colnames(Df) |
|
2275 |
+ # updateSelectInput(session, "ColumnSelect_Xaxis", choices = c(xs)) |
|
2276 |
+ # rm(Df) |
|
2277 |
+ # } |
|
2278 |
+ # } |
|
2279 |
+ # }) |
|
2280 |
+ # ###ApproachSelect to DimensionSelect Y-Axis |
|
2281 |
+ # observe({ |
|
2282 |
+ # if (!is.null(vals$counts)){ |
|
2283 |
+ # len <- length(SingleCellExperiment::reducedDims(vals$counts)) |
|
2284 |
+ # if (!is.null(input$ApproachSelect_Yaxis) & len > 0){ |
|
2285 |
+ # Df2 <- data.frame(SingleCellExperiment::reducedDim(vals$counts,input$ApproachSelect_Yaxis)) |
|
2286 |
+ # xs2 <- colnames(Df2) |
|
2287 |
+ # xs2 <- sort(xs2, decreasing = TRUE) |
|
2288 |
+ # updateSelectInput(session, "ColumnSelect_Yaxis", choices = c(xs2)) |
|
2289 |
+ # rm(Df2) |
|
2290 |
+ # } |
|
2291 |
+ # } |
|
2292 |
+ # }) |
|
2293 |
+ # ###ApproachSelect to DimensionSelect Colorby |
|
2294 |
+ # observe({ |
|
2295 |
+ # if (!is.null(vals$counts)){ |
|
2296 |
+ # len <- length(SingleCellExperiment::reducedDims(vals$counts)) |
|
2297 |
+ # if (!is.null(input$ApproachSelect_Colorby) & len > 0){ |
|
2298 |
+ # Df3 <- data.frame(SingleCellExperiment::reducedDim(vals$counts,input$ApproachSelect_Colorby)) |
|
2299 |
+ # xs3 <- colnames(Df3) |
|
2300 |
+ # updateSelectInput(session, "ColumnSelect_Colorby", choices = c(xs3)) |
|
2301 |
+ # rm(Df3) |
|
2302 |
+ # } |
|
2303 |
+ # } |
|
2304 |
+ # }) |
|
2305 |
+ # |
|
2306 |
+ # #-+-+-+-+-+-Observe Group by################################################### |
|
2307 |
+ # ###Observe Radio Button Select Value Type |
|
2308 |
+ # observe({ |
|
2309 |
+ # if (!is.null(vals$counts)){ |
|
2310 |
+ # if (input$adjustgroupby != 'None'){ |
|
2311 |
+ # #Integer,level>25# |
|
2312 |
+ # if(is.integer(colData(vals$counts)@listData[[input$adjustgroupby]]) |
|
2313 |
+ # & length(levels(as.factor(colData(vals$counts)@listData[[input$adjustgroupby]])))>25){ |
|
2314 |
+ # updateRadioButtons(session, "SelectValueType", "Categorical or Continuous", |
|
2315 |
+ # choices = c("Categorical", "Continuous"), |
|
2316 |
+ # selected = "Continuous") |
|
2317 |
+ # shinyjs::delay(5,shinyjs::disable("SelectValueType")) |
|
2318 |
+ # #Integer,level<25# |
|
2319 |
+ # }else if(is.integer(colData(vals$counts)@listData[[input$adjustgroupby]]) |
|
2320 |
+ # & length(levels(as.factor(colData(vals$counts)@listData[[input$adjustgroupby]])))<=25){ |
|
2321 |
+ # updateRadioButtons(session, "SelectValueType", "Categorical or Continuous", |
|
2322 |
+ # choices = c("Categorical", "Continuous"), |
|
2323 |
+ # selected = "Categorical") |
|
2324 |
+ # shinyjs::enable("SelectValueType") |
|
2325 |
+ # #Numeric,noninteger# |
|
2326 |
+ # }else if(is.numeric(colData(vals$counts)@listData[[input$adjustgroupby]])){ |
|
2327 |
+ # updateRadioButtons(session, "SelectValueType", "Categorical or Continuous", |
|
2328 |
+ # choices = c("Categorical", "Continuous"), |
|
2329 |
+ # selected = "Continuous") |
|
2330 |
+ # shinyjs::delay(5,shinyjs::disable("SelectValueType")) |
|
2331 |
+ # #Categorical# |
|
2332 |
+ # }else{ |
|
2333 |
+ # updateRadioButtons(session, "SelectValueType", "Categorical or Continuous", |
|
2334 |
+ # choices = c("Categorical", "Continuous"), |
|
2335 |
+ # selected = "Categorical") |
|
2336 |
+ # shinyjs::delay(5,shinyjs::disable("SelectValueType"))} |
|
2337 |
+ # } |
|
2338 |
+ # } |
|
2339 |
+ # })#observe_end |
|
2340 |
+ # |
|
2341 |
+ # ###Observe Check Box Check Binning & Text Input Number of Bins: |
|
2342 |
+ # |
|
2343 |
+ # observe({ |
|
2344 |
+ # if (!is.null(vals$counts)){ |
|
2345 |
+ # if (input$adjustgroupby != 'None'){ |
|
2346 |
+ # #Integer,level>25# |
|
2347 |
+ # if(is.integer(colData(vals$counts)@listData[[input$adjustgroupby]]) |
|
2348 |
+ # &length(levels(as.factor(colData(vals$counts)@listData[[input$adjustgroupby]])))>25){ |
|
2349 |
+ # updateCheckboxInput(session,"checkbinning","Perform Binning", value = TRUE) |
|
2350 |
+ # shinyjs::delay(5,shinyjs::disable("checkbinning")) |
|
2351 |
+ # shinyjs::enable("adjustbinning") |
|
2352 |
+ # #Integer,level<25,continuous |
|
2353 |
+ # }else if(is.integer(colData(vals$counts)@listData[[input$adjustgroupby]]) |
|
2354 |
+ # &length(levels(as.factor(colData(vals$counts)@listData[[input$adjustgroupby]])))<=25 |
|
2355 |
+ # &input$SelectValueType == "Continuous"){ |
|
2356 |
+ # updateCheckboxInput(session,"checkbinning","Perform Binning", value = TRUE) |
|
2357 |
+ # shinyjs::delay(5,shinyjs::disable("checkbinning")) |
|
2358 |
+ # shinyjs::enable("adjustbinning") |
|
2359 |
+ # #Integer,level<25,Categorical |
|
2360 |
+ # }else if(is.integer(colData(vals$counts)@listData[[input$adjustgroupby]]) |
|
2361 |
+ # &length(levels(as.factor(colData(vals$counts)@listData[[input$adjustgroupby]])))<=25 |
|
2362 |
+ # &input$SelectValueType == "Categorical"){ |
|
2363 |
+ # updateCheckboxInput(session,"checkbinning","Perform Binning", value = FALSE) |
|
2364 |
+ # shinyjs::delay(5,shinyjs::disable("checkbinning")) |
|
2365 |
+ # shinyjs::disable("adjustbinning") |
|
2366 |
+ # #Numeric,noninteger |
|
2367 |
+ # }else if(is.numeric(colData(vals$counts)@listData[[input$adjustgroupby]])){ |
|
2368 |
+ # updateCheckboxInput(session,"checkbinning","Perform Binning", value = TRUE) |
|
2369 |
+ # shinyjs::delay(5,shinyjs::disable("checkbinning")) |
|
2370 |
+ # shinyjs::enable("adjustbinning") |
|
2371 |
+ # #Categorical |
|
2372 |
+ # }else{updateCheckboxInput(session,"checkbinning","Perform Binning", value = FALSE) |
|
2373 |
+ # shinyjs::delay(5,shinyjs::disable("checkbinning")) |
|
2374 |
+ # shinyjs::disable("adjustbinning") |
|
2375 |
+ # } |
|
2376 |
+ # } |
|
2377 |
+ # } |
|
2378 |
+ # })#observe_end |
|
2379 |
+ # |
|
2380 |
+ # #-+-+-+-+-+-Observe Color bye################################################### |
|
2381 |
+ # ###Observe Radio Button Select Value Type |
|
2382 |
+ # observe({ |
|
2383 |
+ # if (!is.null(vals$counts)){ |
|
2384 |
+ # if (input$TypeSelect_Colorby != 'Pick a Color'){ |
|
2385 |
+ # ###If Cell Annotation############################################################### |
|
2386 |
+ # if(input$TypeSelect_Colorby == 'Cell Annotation'){ |
|
2387 |
+ # ###If Cell Annotation numeric |
|
2388 |
+ # if(!is.numeric(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]])){ |
|
2389 |
+ # updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2390 |
+ # choices = c("Categorical", "Continuous"), |
|
2391 |
+ # selected = "Categorical") |
|
2392 |
+ # shinyjs::delay(5,shinyjs::disable("SelectColorType")) |
|
2393 |
+ # |
|
2394 |
+ # |
|
2395 |
+ # }else if(is.integer(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]]) |
|
2396 |
+ # &length(levels(as.factor(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]])))<=25){ |
|
2397 |
+ # updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2398 |
+ # choices = c("Categorical", "Continuous"), |
|
2399 |
+ # selected = "Categorical") |
|
2400 |
+ # shinyjs::enable("SelectColorType") |
|
2401 |
+ # |
|
2402 |
+ # }else{updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2403 |
+ # choices = c("Categorical", "Continuous"), |
|
2404 |
+ # selected = "Continuous") |
|
2405 |
+ # shinyjs::delay(5,shinyjs::disable("SelectColorType"))} |
|
2406 |
+ # |
|
2407 |
+ # ###If ReducedData########################################################## |
|
2408 |
+ # }else if(input$TypeSelect_Colorby == 'Reduced Dimensions'){ |
|
2409 |
+ # Dfcolor <- data.frame(reducedDims(vals$counts)@listData[[input$ApproachSelect_Colorby]]) |
|
2410 |
+ # if(input$ColumnSelect_Colorby %in% colnames(Dfcolor)){ |
|
2411 |
+ # Dfcolor <- Dfcolor[which(colnames(Dfcolor) == input$ColumnSelect_Colorby)] |
|
2412 |
+ # ###If ReducedData numeric |
|
2413 |
+ # |
|
2414 |
+ # if(!is.numeric(Dfcolor[,1])){ |
|
2415 |
+ # updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2416 |
+ # choices = c("Categorical", "Continuous"), |
|
2417 |
+ # selected = "Categorical") |
|
2418 |
+ # shinyjs::delay(5,shinyjs::disable("SelectColorType")) |
|
2419 |
+ # |
|
2420 |
+ # |
|
2421 |
+ # }else if(is.integer(Dfcolor[,1]) |
|
2422 |
+ # &length(levels(as.factor(Dfcolor[,1])))<=25){ |
|
2423 |
+ # updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2424 |
+ # choices = c("Categorical", "Continuous"), |
|
2425 |
+ # selected = "Categorical") |
|
2426 |
+ # shinyjs::enable("SelectColorType") |
|
2427 |
+ # |
|
2428 |
+ # }else{updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2429 |
+ # choices = c("Categorical", "Continuous"), |
|
2430 |
+ # selected = "Continuous") |
|
2431 |
+ # shinyjs::delay(5,shinyjs::disable("SelectColorType"))} |
|
2432 |
+ # } |
|
2433 |
+ # ###If Expression Assays########################################################### |
|
2434 |
+ # }else{Dfassay <- assay(vals$counts, input$AdvancedMethodSelect_Colorby) |
|
2435 |
+ # if(input$GeneSelect_Assays_Colorby %in% rownames(Dfassay)){ |
|
2436 |
+ # Dfassay <- data.frame(Dfassay[which(rownames(Dfassay)== input$GeneSelect_Assays_Colorby),]) |
|
2437 |
+ # |
|
2438 |
+ # if(!is.numeric(Dfassay[,1])){ |
|
2439 |
+ # updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2440 |
+ # choices = c("Categorical", "Continuous"), |
|
2441 |
+ # selected = "Categorical") |
|
2442 |
+ # shinyjs::delay(5,shinyjs::disable("SelectColorType")) |
|
2443 |
+ # |
|
2444 |
+ # |
|
2445 |
+ # }else if(is.integer(Dfassay[,1]) |
|
2446 |
+ # &length(levels(as.factor(Dfassay[,1])))<=25){ |
|
2447 |
+ # updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2448 |
+ # choices = c("Categorical", "Continuous"), |
|
2449 |
+ # selected = "Categorical") |
|
2450 |
+ # shinyjs::enable("SelectColorType") |
|
2451 |
+ # |
|
2452 |
+ # }else{updateRadioButtons(session, "SelectColorType", "Categorical or Continuous", |
|
2453 |
+ # choices = c("Categorical", "Continuous"), |
|
2454 |
+ # selected = "Continuous") |
|
2455 |
+ # shinyjs::delay(5,shinyjs::disable("SelectColorType"))} |
|
2456 |
+ # } |
|
2457 |
+ # } |
|
2458 |
+ # } |
|
2459 |
+ # } |
|
2460 |
+ # })###observe_end |
|
2461 |
+ # |
|
2462 |
+ # ###Observe Check Box Check Binning & Text Input Number of Bins: |
|
2463 |
+ # observe({ |
|
2464 |
+ # if (!is.null(vals$counts)){ |
|
2465 |
+ # ###If Cell Annotation############################################################### |
|
2466 |
+ # if(input$TypeSelect_Colorby != 'Pick a Color'){ |
|
2467 |
+ # |
|
2468 |
+ # if(input$TypeSelect_Colorby == 'Cell Annotation'){ |
|
2469 |
+ # if(!is.numeric(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]])){ |
|
2470 |
+ # updateCheckboxInput(session,"checkColorbinning","Perform Binning", value = FALSE) |
|
2471 |
+ # shinyjs::delay(5,shinyjs::disable("checkColorbinning")) |
|
2472 |
+ # shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2473 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda")) |
|
2474 |
+ # |
|
2475 |
+ # }else if(is.integer(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]]) |
|
2476 |
+ # &length(levels(as.factor(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]])))<=25 |
|
2477 |
+ # &input$SelectColorType == 'Categorical'){ |
|
2478 |
+ # updateCheckboxInput(session,"checkColorbinning","Perform Binning", value = FALSE) |
|
2479 |
+ # shinyjs::delay(5,shinyjs::disable("checkColorbinning")) |
|
2480 |
+ # shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2481 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda")) |
|
2482 |
+ # |
|
2483 |
+ # }else if(is.integer(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]]) |
|
2484 |
+ # &length(levels(as.factor(colData(vals$counts)@listData[[input$AnnotationSelect_Colorby]])))<=25 |
|
2485 |
+ # &input$SelectColorType == 'Continuous'){ |
|
2486 |
+ # |
|
2487 |
+ # shinyjs::enable("checkColorbinning") |
|
2488 |
+ # if(input$checkColorbinning == TRUE){ |
|
2489 |
+ # shinyjs::enable("adjustColorbinning") |
|
2490 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda"))} |
|
2491 |
+ # |
|
2492 |
+ # else{ |
|
2493 |
+ # shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2494 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("RdYlBu",color_seqdiv))} |
|
2495 |
+ # |
|
2496 |
+ # }else{ |
|
2497 |
+ # |
|
2498 |
+ # shinyjs::enable("checkColorbinning") |
|
2499 |
+ # if(input$checkColorbinning == TRUE){ |
|
2500 |
+ # shinyjs::enable("adjustColorbinning") |
|
2501 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda"))} |
|
2502 |
+ # |
|
2503 |
+ # else{ |
|
2504 |
+ # shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2505 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("RdYlBu",color_seqdiv))} |
|
2506 |
+ # } |
|
2507 |
+ # |
|
2508 |
+ # |
|
2509 |
+ # ###If Reduce Dimensions############################################################## |
|
2510 |
+ # }else if(input$TypeSelect_Colorby == 'Reduced Dimensions'){ |
|
2511 |
+ # Dfcolor <- data.frame(reducedDims(vals$counts)@listData[[input$ApproachSelect_Colorby]]) |
|
2512 |
+ # if(input$ColumnSelect_Colorby %in% colnames(Dfcolor)){ |
|
2513 |
+ # Dfcolor <- Dfcolor[which(colnames(Dfcolor) == input$ColumnSelect_Colorby)] |
|
2514 |
+ # |
|
2515 |
+ # if(!is.numeric(Dfcolor[,1])){ |
|
2516 |
+ # updateCheckboxInput(session,"checkColorbinning","Perform Binning", value = FALSE) |
|
2517 |
+ # shinyjs::delay(5,shinyjs::disable("checkColorbinning")) |
|
2518 |
+ # shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2519 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda")) |
|
2520 |
+ # |
|
2521 |
+ # }else if(is.integer(Dfcolor[,1]) |
|
2522 |
+ # &length(levels(as.factor(Dfcolor[,1])))<=25 |
|
2523 |
+ # &input$SelectColorType == 'Categorical'){ |
|
2524 |
+ # updateCheckboxInput(session,"checkColorbinning","Perform Binning", value = FALSE) |
|
2525 |
+ # shinyjs::delay(5,shinyjs::disable("checkColorbinning")) |
|
2526 |
+ # shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2527 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda")) |
|
2528 |
+ # |
|
2529 |
+ # }else if(is.integer(Dfcolor[,1]) |
|
2530 |
+ # &length(levels(as.factor(Dfcolor[,1])))<=25 |
|
2531 |
+ # &input$SelectColorType == 'Continuous'){ |
|
2532 |
+ # |
|
2533 |
+ # shinyjs::enable("checkColorbinning") |
|
2534 |
+ # if(input$checkColorbinning == TRUE){ |
|
2535 |
+ # shinyjs::enable("adjustColorbinning") |
|
2536 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda"))} |
|
2537 |
+ # |
|
2538 |
+ # else{ |
|
2539 |
+ # shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2540 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("RdYlBu",color_seqdiv))} |
|
2541 |
+ # |
|
2542 |
+ # }else{ |
|
2543 |
+ # |
|
2544 |
+ # shinyjs::enable("checkColorbinning") |
|
2545 |
+ # if(input$checkColorbinning == TRUE){ |
|
2546 |
+ # shinyjs::enable("adjustColorbinning") |
|
2547 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda"))} |
|
2548 |
+ # |
|
2549 |
+ # else{ |
|
2550 |
+ # shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2551 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("RdYlBu",color_seqdiv))} |
|
2552 |
+ # } |
|
2553 |
+ # } |
|
2554 |
+ # |
|
2555 |
+ # |
|
2556 |
+ # ###If Expression Assays########################################################## |
|
2557 |
+ # }else{Dfassay <- assay(vals$counts, input$AdvancedMethodSelect_Colorby) |
|
2558 |
+ # if(input$GeneSelect_Assays_Colorby %in% rownames(Dfassay)){ |
|
2559 |
+ # Dfassay <- data.frame(Dfassay[which(rownames(Dfassay)== input$GeneSelect_Assays_Colorby),]) |
|
2560 |
+ # |
|
2561 |
+ # if(!is.numeric(Dfassay[,1])){ |
|
2562 |
+ # updateCheckboxInput(session,"checkColorbinning","Perform Binning", value = FALSE) |
|
2563 |
+ # shinyjs::delay(5,shinyjs::disable("checkColorbinning")) |
|
2564 |
+ # shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2565 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda")) |
|
2566 |
+ # |
|
2567 |
+ # }else if(is.integer(Dfassay[,1]) |
|
2568 |
+ # &length(levels(as.factor(Dfassay[,1])))<=25 |
|
2569 |
+ # &input$SelectColorType == 'Categorical'){ |
|
2570 |
+ # updateCheckboxInput(session,"checkColorbinning","Perform Binning", value = FALSE) |
|
2571 |
+ # shinyjs::delay(5,shinyjs::disable("checkColorbinning")) |
|
2572 |
+ # shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2573 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda")) |
|
2574 |
+ # |
|
2575 |
+ # }else if(is.integer(Dfassay[,1]) |
|
2576 |
+ # &length(levels(as.factor(Dfassay[,1])))<=25 |
|
2577 |
+ # &input$SelectColorType == 'Continuous'){ |
|
2578 |
+ # |
|
2579 |
+ # shinyjs::enable("checkColorbinning") |
|
2580 |
+ # if(input$checkColorbinning == TRUE){ |
|
2581 |
+ # shinyjs::enable("adjustColorbinning") |
|
2582 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda"))} |
|
2583 |
+ # |
|
2584 |
+ # else{ |
|
2585 |
+ # shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2586 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("RdYlBu",color_seqdiv))} |
|
2587 |
+ # |
|
2588 |
+ # }else{ |
|
2589 |
+ # |
|
2590 |
+ # shinyjs::enable("checkColorbinning") |
|
2591 |
+ # if(input$checkColorbinning == TRUE){ |
|
2592 |
+ # shinyjs::enable("adjustColorbinning") |
|
2593 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("ggplot","Celda"))} |
|
2594 |
+ # |
|
2595 |
+ # else{ |
|
2596 |
+ # shinyjs::delay(5,shinyjs::disable("adjustColorbinning")) |
|
2597 |
+ # updateSelectizeInput(session,"adjustbrewer", label = "Color Palettes:", choices = c("RdYlBu",color_seqdiv)) |
|
2598 |
+ # } |
|
2599 |
+ # } |
|
2600 |
+ # } |
|
2601 |
+ # }#Dfassay_end |
|
2602 |
+ # }#ifnot_end |
|
2603 |
+ # } |
|
2604 |
+ # })###observe_end |
|
2605 |
+ # |
|
2619 | 2606 |
|
2620 | 2607 |
|
2621 | 2608 |
#-+-+-+-+-+-cellviewer prepare step1: choose data. (next steps included)########################################################### |
... | ... |
@@ -4333,233 +4320,216 @@ shinyServer(function(input, output, session) { |
4333 | 4320 |
#reactive values object to store all objects to be used in seurat workflow |
4334 | 4321 |
seuratWorkflow <- reactiveValues() |
4335 | 4322 |
|
4336 |
- #Upload sce object (rds file) |
|
4337 |
- observeEvent(seuratWorkflow$sce_rds_file, { |
|
4338 |
- if (!is.null(seuratWorkflow$sce_rds_file)) { |
|
4339 |
- if (!methods::is(seuratWorkflow$sce_rds_file, "Seurat")) { #sce_rds_file is a sce filepath |
|
4340 |
- seuratWorkflow$seuratObject <- .sceToSeurat(seuratWorkflow$sce_rds_file$datapath) |
|
4341 |
- } |
|
4342 |
- else if (methods::is(seuratWorkflow$sce_rds_file, "Seurat")) { #sce_rds_file is a seurat object |
|
4343 |
- seuratWorkflow$seuratObject <- seuratWorkflow$sce_rds_file |
|
4344 |
- } |
|
4345 |
- vals$counts@metadata$seuratSelectedAssay <- names(assays(vals$counts))[1] |
|
4346 |
- seuratWorkflow$geneNamesSCE <- .rowNamesSCE(vals$counts) |
|
4347 |
- seuratWorkflow$geneNamesSeurat <- .rowNamesSeurat(seuratWorkflow$seuratObject) |
|
4348 |
- updateSelectInput(session = session, inputId = "seuratSelectNormalizationAssay", choices = names(assays(vals$counts))) |
|
4349 |
- } |
|
4350 |
- }) |
|
4351 |
- |
|
4352 |
- #Display highly variable genes |
|
4353 |
- output$hvg_output <- renderText({ |
|
4354 |
- if (!is.null(vals$counts)) { |
|
4355 |
- if (!is.null(vals$counts@metadata[["seurat"]])) { |
|
4356 |
- if (length(slot(vals$counts@metadata[["seurat"]], "assays")[["RNA"]]@var.features) > 0) { |
|
4357 |
- .seuratGetVariableFeatures(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, input$hvg_no_features_view) |
|
4358 |
- } |
|
4359 |
- } |
|
4360 |
- } |
|
4361 |
- }) |
|
4362 |
- |
|
4363 | 4323 |
#Perform normalization |
4364 | 4324 |
observeEvent(input$normalize_button, { |
4365 |
- if (!is.null(vals$counts)) { |
|
4366 |
- withProgress(message = "Normalizing", max = 1, value = 1, { |
|
4367 |
- vals$counts@metadata$seuratSelectedAssay <- input$seuratSelectNormalizationAssay |
|
4368 |
- vals$counts <- seuratNormalizeData(inSCE = vals$counts, useAssay = input$seuratSelectNormalizationAssay, geneNames = seuratWorkflow$geneNamesSeurat, input$normalization_method, as.numeric(input$scale_factor)) |
|
4369 |
- updateAssayInputs() |
|
4370 |
- }) |
|
4371 |
- updateCollapse(session = session, "SeuratUI", style = list("Normalize Data" = "danger")) |
|
4372 |
- showNotification("Normalization Complete") |
|
4373 |
- } |
|
4374 |
- else { |
|
4375 |
- showNotification("Please input dataset (rds file) before normalizing data!", type = "error") |
|
4376 |
- } |
|
4325 |
+ if (!is.null(vals$counts)) { |
|
4326 |
+ withProgress(message = "Normalizing", max = 1, value = 1, { |
|
4327 |
+ vals$counts <- seuratNormalizeData(inSCE = vals$counts, |
|
4328 |
+ useAssay = input$seuratSelectNormalizationAssay, |
|
4329 |
+ normAssayName = "seuratNormData", |
|
4330 |
+ normalizationMethod = input$normalization_method, |
|
4331 |
+ scaleFactor = as.numeric(input$scale_factor)) |
|
4332 |
+ updateAssayInputs() |
|
4333 |
+ }) |
|
4334 |
+ updateCollapse(session = session, "SeuratUI", style = list("Normalize Data" = "danger")) |
|
4335 |
+ showNotification("Normalization Complete") |
|
4336 |
+ } |
|
4377 | 4337 |
}) |
4378 | 4338 |
|
4379 | 4339 |
#Perform scaling |
4380 | 4340 |
observeEvent(input$scale_button, { |
4381 | 4341 |
if (!is.null(vals$counts)) { |
4382 | 4342 |
withProgress(message = "Scaling", max = 1, value = 1, { |
4383 |
- vals$counts <- seuratScaleData(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, input$model.use, input$do.scale, input$do.center, input$scale.max) |
|
4343 |
+ vals$counts <- seuratScaleData(inSCE = vals$counts, |
|
4344 |
+ useAssay = "seuratNormData", |
|
4345 |
+ scaledAssayName = "seuratScaledData", |
|
4346 |
+ model = input$model.use, |
|
4347 |
+ scale = input$do.scale, |
|
4348 |
+ center = input$do.center, |
|
4349 |
+ scaleMax = input$scale.max) |
|
4384 | 4350 |
updateAssayInputs() |
4385 | 4351 |
}) |
4386 | 4352 |
updateCollapse(session = session, "SeuratUI", style = list("Scale Data" = "danger")) |
4387 | 4353 |
showNotification("Scale Complete") |
4388 | 4354 |
} |
4389 | 4355 |
else { |
4390 |
- showNotification("Please input dataset (rds file) before scaling data!", type = "error") |
|
4356 |
+ showNotification("Please perform normalization before scaling the data.", type = "error") |
|
4391 | 4357 |
} |
4392 | 4358 |
}) |
4393 | 4359 |
|
4360 |
+ #Find HVG |
|
4361 |
+ observeEvent(input$find_hvg_button, { |
|
4362 |
+ if (!is.null(vals$counts) |
|
4363 |
+ && "seuratNormData" %in% assayNames(vals$counts) |
|
4364 |
+ && "seuratScaledData" %in% assayNames(vals$counts)) { |
|
4365 |
+ withProgress(message = "Finding highly variable genes", max = 1, value = 1, { |
|
4366 |
+ vals$counts <- seuratFindHVG(inSCE = vals$counts, |
|
4367 |
+ useAssay = "seuratScaledData", |
|
4368 |
+ hvgMethod = input$hvg_method, |
|
4369 |
+ hvgNumber = as.numeric(input$hvg_no_features)) |
|
4370 |
+ }) |
|
4371 |
+ withProgress(message = "Plotting HVG", max = 1, value = 1, { |
|
4372 |
+ seuratWorkflow$plotObject$HVG <- seuratPlotHVG(vals$counts) |
|
4373 |
+ }) |
|
4374 |
+ updateCollapse(session = session, "SeuratUI", style = list("Highly Variable Genes" = "danger")) |
|
4375 |
+ showNotification("Find HVG Complete") |
|
4376 |
+ } |
|
4377 |
+ else if (!"seuratNormData" %in% assayNames(vals$counts)) { |
|
4378 |
+ showNotification("Please normalize data before computing highly variable genes.", type = "error") |
|
4379 |
+ } |
|
4380 |
+ else if (!"seuratScaledData" %in% assayNames(vals$counts)) { |
|
4381 |
+ showNotification("Please scale data before computing highly variable genes.", type = "error") |
|
4382 |
+ } |
|
4383 |
+ else { |
|
4384 |
+ showNotification("An error occurred while computing highly variable genes.", type = "error") |
|
4385 |
+ } |
|
4386 |
+ }) |
|
4387 |
+ |
|
4388 |
+ #Display highly variable genes |
|
4389 |
+ output$hvg_output <- renderText({ |
|
4390 |
+ if (!is.null(vals$counts)) { |
|
4391 |
+ if (!is.null(vals$counts@metadata$seurat$obj)) { |
|
4392 |
+ if (length(slot(vals$counts@metadata$seurat$obj, "assays")[["RNA"]]@var.features) > 0) { |
|
4393 |
+ .seuratGetVariableFeatures(vals$counts, input$hvg_no_features_view) |
|
4394 |
+ } |
|
4395 |
+ } |
|
4396 |
+ } |
|
4397 |
+ }) |
|
4398 |
+ |
|
4394 | 4399 |
#Run PCA |
4395 | 4400 |
observeEvent(input$run_pca_button, { |
4396 |
- if (!is.null(vals$counts)) { |
|
4397 |
- if (!is.null(vals$counts@metadata[["seurat"]])) { |
|
4398 |
- if ((length(slot(vals$counts@metadata[["seurat"]], "assays")[["RNA"]]@scale.data) > 0) && (length(slot(vals$counts@metadata[["seurat"]], "assays")[["RNA"]]@var.features) > 0)) { |
|
4399 |
- withProgress(message = "Running PCA", max = 1, value = 1, { |
|
4400 |
- vals$counts <- seuratPCA(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, input$pca_no_components) |
|
4401 |
- seuratWorkflow$numberOfReductionComponents$pca <- dim(convertSCEToSeurat(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat)[["pca"]])[2] |
|
4402 |
- }) |
|
4403 |
- withProgress(message = "Plotting PCA", max = 1, value = 1, { |
|
4404 |
- seuratWorkflow$plotObject$PCA <- seuratReductionPlot(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, "pca") |
|
4405 |
- }) |
|
4406 |
- if (input$pca_compute_elbow) { |
|
4407 |
- withProgress(message = "Generating Elbow Plot", max = 1, value = 1, { |
|
4408 |
- seuratWorkflow$numberOfReductionComponents$significantPC <- .computeSignificantPC(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat) |
|
4409 |
- seuratWorkflow$plotObject$Elbow <- seuratElbowPlot(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, seuratWorkflow$numberOfReductionComponents$significantPC) |
|
4410 |
- }) |
|
4411 |
- } |
|
4412 |
- if (input$pca_compute_jackstraw) { |
|
4413 |
- withProgress(message = "Generating JackStraw Plot", max = 1, value = 1, { |
|
4414 |
- vals$counts <- seuratComputeJackStraw(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, input$pca_no_components) |
|
4415 |
- seuratWorkflow$plotObject$JackStraw <- seuratJackStrawPlot(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, input$pca_no_components) |
|
4416 |
- }) |
|
4417 |
- } |
|
4418 |
- if (input$pca_compute_heatmap) { |
|
4419 |
- withProgress(message = "Generating Heatmap Plot", max = 1, value = 1, { |
|
4420 |
- seuratWorkflow$plotObject$HeatmapCompute <- seuratComputeHeatmap(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, input$pca_no_components) |
|
4421 |
- updatePickerInput(session = session, inputId = "picker_dimheatmap_components_pca", choices = .getPCAComponentNames(seuratWorkflow$numberOfReductionComponents$pca)) |
|
4422 |
- }) |
|
4423 |
- } |
|
4424 |
- addTooltip(session = session, id = "reduction_tsne_count", paste("Maximum components available:", seuratWorkflow$numberOfReductionComponents$pca), placement = "bottom", trigger = "hover") |
|
4425 |
- addTooltip(session = session, id = "reduction_umap_count", paste("Maximum components available:", seuratWorkflow$numberOfReductionComponents$pca), placement = "bottom", trigger = "hover") |
|
4426 |
- addTooltip(session = session, id = "reduction_clustering_count", paste("Maximum components available:", seuratWorkflow$numberOfReductionComponents$pca), placement = "bottom", trigger = "hover") |
|
4427 |
- updateCollapse(session = session, "SeuratUI", style = list("Dimensionality Reduction" = "danger")) |
|
4428 |
- showNotification("PCA Complete") |
|
4429 |
- } |
|
4430 |
- else { |
|
4431 |
- showNotification("Please scale data and find highly variable genes before computing pca!", type = "error") |
|
4432 |
- } |
|
4433 |
- } |
|
4401 |
+ req(vals$counts) |
|
4402 |
+ withProgress(message = "Running PCA", max = 1, value = 1, { |
|
4403 |
+ vals$counts <- seuratPCA(inSCE = vals$counts, |
|
4404 |
+ useAssay = "seuratScaledData", |
|
4405 |
+ reducedDimName = "seuratPCA", |
|
4406 |
+ nPCs = input$pca_no_components) |
|
4407 |
+ seuratWorkflow$numberOfReductionComponents$pca <- dim(convertSCEToSeurat(vals$counts)[["pca"]])[2] |
|
4408 |
+ }) |
|
4409 |
+ withProgress(message = "Plotting PCA", max = 1, value = 1, { |
|
4410 |
+ seuratWorkflow$plotObject$PCA <- seuratReductionPlot(inSCE = vals$counts, |
|
4411 |
+ useReduction = "pca") |
|
4412 |
+ }) |
|
4413 |
+ if (input$pca_compute_elbow) { |
|
4414 |
+ withProgress(message = "Generating Elbow Plot", max = 1, value = 1, { |
|
4415 |
+ seuratWorkflow$numberOfReductionComponents$significantPC <- .computeSignificantPC(vals$counts) |
|
4416 |
+ seuratWorkflow$plotObject$Elbow <- seuratElbowPlot(inSCE = vals$counts, |
|
4417 |
+ significantPC = seuratWorkflow$numberOfReductionComponents$significantPC) |
|
4418 |
+ }) |
|
4434 | 4419 |
} |
4435 |
- else { |
|
4436 |
- showNotification("Please input dataset (rds file) before computing pca!", type = "error") |
|
4420 |
+ if (input$pca_compute_jackstraw) { |
|
4421 |
+ withProgress(message = "Generating JackStraw Plot", max = 1, value = 1, { |
|
4422 |
+ vals$counts <- seuratComputeJackStraw(inSCE = vals$counts, |
|
4423 |
+ useAssay = "seuratScaledData", |
|
4424 |
+ dims = input$pca_no_components) |
|
4425 |
+ seuratWorkflow$plotObject$JackStraw <- seuratJackStrawPlot(inSCE = vals$counts, |
|
4426 |
+ dims = input$pca_no_components) |
|
4427 |
+ }) |
|
4437 | 4428 |
} |
4429 |
+ if (input$pca_compute_heatmap) { |
|
4430 |
+ withProgress(message = "Generating Heatmaps", max = 1, value = 1, { |
|
4431 |
+ seuratWorkflow$plotObject$HeatmapCompute <- seuratComputeHeatmap(inSCE = vals$counts, |
|
4432 |
+ useAssay = "seuratScaledData", |
|
4433 |
+ useReduction = "pca", |
|
4434 |
+ dims = input$pca_no_components, |
|
4435 |
+ combine = FALSE, |
|
4436 |
+ fast = FALSE) |
|
4437 |
+ updatePickerInput(session = session, inputId = "picker_dimheatmap_components_pca", choices = .getPCAComponentNames(seuratWorkflow$numberOfReductionComponents$pca)) |
|
4438 |
+ }) |
|
4439 |
+ } |
|
4440 |
+ addTooltip(session = session, id = "reduction_tsne_count", paste("Maximum components available:", seuratWorkflow$numberOfReductionComponents$pca), placement = "bottom", trigger = "hover") |
|
4441 |
+ addTooltip(session = session, id = "reduction_umap_count", paste("Maximum components available:", seuratWorkflow$numberOfReductionComponents$pca), placement = "bottom", trigger = "hover") |
|
4442 |
+ addTooltip(session = session, id = "reduction_clustering_count", paste("Maximum components available:", seuratWorkflow$numberOfReductionComponents$pca), placement = "bottom", trigger = "hover") |
|
4443 |
+ updateCollapse(session = session, "SeuratUI", style = list("Dimensionality Reduction" = "danger")) |
|
4444 |
+ showNotification("PCA Complete") |
|
4438 | 4445 |
}) |
4439 | 4446 |
|
4440 | 4447 |
#Run ICA |
4441 | 4448 |
observeEvent(input$run_ica_button, { |
4442 |
- if (!is.null(vals$counts)) { |
|
4443 |
- if (!is.null(vals$counts@metadata[["seurat"]])) { |
|
4444 |
- if ((length(slot(vals$counts@metadata[["seurat"]], "assays")[["RNA"]]@scale.data) > 0) && (length(slot(vals$counts@metadata[["seurat"]], "assays")[["RNA"]]@var.features) > 0)) { |
|
4445 |
- withProgress(message = "Running ICA", max = 1, value = 1, { |
|
4446 |
- vals$counts <- seuratICA(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, input$ica_no_components) |
|
4447 |
- seuratWorkflow$numberOfReductionComponents$ica <- dim(convertSCEToSeurat(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat)[["ica"]])[2] |
|
4448 |
- }) |
|
4449 |
- withProgress(message = "Plotting ICA", max = 1, value = 1, { |
|
4450 |
- seuratWorkflow$plotObject$ICA <- seuratReductionPlot(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, "ica") |
|
4451 |
- }) |
|
4452 |
- updateCollapse(session = session, "SeuratUI", style = list("Dimensionality Reduction" = "danger")) |
|
4453 |
- showNotification("ICA Complete") |
|
4454 |
- } |
|
4455 |
- else { |
|
4456 |
- showNotification("Please scale data and find highly variable genes before computing ica!", type = "error") |
|
4457 |
- } |
|
4458 |
- } |
|
4459 |
- } |
|
4460 |
- else { |
|
4461 |
- showNotification("Please input dataset (rds file) before computing ica!", type = "error") |
|
4462 |
- } |
|
4463 |
- }) |
|
4464 |
- |
|
4465 |
- #Find HVG |
|
4466 |
- observeEvent(input$find_hvg_button, { |
|
4467 |
- if (!is.null(vals$counts) |
|
4468 |
- && "seuratNormalizedData" %in% assayNames(vals$counts) |
|
4469 |
- && "seuratScaledData" %in% assayNames(vals$counts)) { |
|
4470 |
- withProgress(message = "Finding highly variable genes", max = 1, value = 1, { |
|
4471 |
- vals$counts <- seuratFindHVG(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, input$hvg_method, as.numeric(input$hvg_no_features)) |
|
4472 |
- }) |
|
4473 |
- withProgress(message = "Plotting HVG", max = 1, value = 1, { |
|
4474 |
- seuratWorkflow$plotObject$HVG <- seuratPlotHVG(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat) |
|
4475 |
- }) |
|
4476 |
- updateCollapse(session = session, "SeuratUI", style = list("Highly Variable Genes" = "danger")) |
|
4477 |
- showNotification("Find HVG Complete") |
|
4478 |
- } |
|
4479 |
- else if (is.null(vals$counts)) { |
|
4480 |
- showNotification("Please input dataset (rds file) before computing highly variable genes!", type = "error") |
|
4481 |
- } |
|
4482 |
- else if (!"seuratNormalizedData" %in% assayNames(vals$counts)) { |
|
4483 |
- showNotification("Please normalize data before computing highly variable genes!", type = "error") |
|
4484 |
- } |
|
4485 |
- else if (!"seuratScaledData" %in% assayNames(vals$counts)) { |
|
4486 |
- showNotification("Please scale data before computing highly variable genes!", type = "error") |
|
4487 |
- } |
|
4488 |
- else { |
|
4489 |
- showNotification("An error occurred while computing highly variable genes!", type = "error") |
|
4490 |
- } |
|
4449 |
+ req(vals$counts) |
|
4450 |
+ withProgress(message = "Running ICA", max = 1, value = 1, { |
|
4451 |
+ vals$counts <- seuratICA(inSCE = vals$counts, |
|
4452 |
+ useAssay = "seuratScaledData", |
|
4453 |
+ reducedDimName = "seuratICA", |
|
4454 |
+ nics = input$ica_no_components) |
|
4455 |
+ seuratWorkflow$numberOfReductionComponents$ica <- dim(convertSCEToSeurat(vals$counts)[["ica"]])[2] |
|
4456 |
+ }) |
|
4457 |
+ withProgress(message = "Plotting ICA", max = 1, value = 1, { |
|
4458 |
+ seuratWorkflow$plotObject$ICA <- seuratReductionPlot(inSCE = vals$counts, |
|
4459 |
+ useReduction = "ica") |
|
4460 |
+ }) |
|
4461 |
+ updateCollapse(session = session, "SeuratUI", style = list("Dimensionality Reduction" = "danger")) |
|
4462 |
+ showNotification("ICA Complete") |
|
4491 | 4463 |
}) |
4492 | 4464 |
|
4493 | 4465 |
#Find clusters |
4494 | 4466 |
observeEvent(input$find_clusters_button, { |
4495 |
- if (!is.null(vals$counts)) { |
|
4496 |
- if (!is.null(vals$counts@metadata[["seurat"]])) { |
|
4497 |
- if (!is.null(slot(vals$counts@metadata[["seurat"]], "reductions")[[input$reduction_clustering_method]])) { |
|
4498 |
- withProgress(message = "Finding clusters", max = 1, value = 1, { |
|
4499 |
- vals$counts <- seuratFindClusters(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, reduction = input$reduction_clustering_method, dims = input$reduction_clustering_count, algorithm = input$algorithm.use, groupSingletons = input$group.singletons) |
|
4500 |
- }) |
|
4501 |
- updateCollapse(session = session, "SeuratUI", style = list("Clustering" = "danger")) |
|
4502 |
- showNotification("Find Clusters Complete") |
|
4503 |
- } |
|
4504 |
- else { |
|
4505 |
- showNotification("Please compute pca/ica before processing clusters!", type = "error") |
|
4506 |
- } |
|
4507 |
- } |
|
4508 |
- else { |
|
4509 |
- showNotification("Please normalize data before computing umap!", type = "error") |
|
4510 |
- } |
|
4511 |
- } |
|
4512 |
- else { |
|
4513 |
- showNotification("Please input dataset (rds file) before computing clusters!", type = "error") |
|
4514 |
- } |
|
4467 |
+ req(vals$counts) |
|
4468 |
+# if (!is.null(vals$counts@metadata[["seurat"]])) { |
|
4469 |
+# if (!is.null(slot(vals$counts@metadata[["seurat"]], "reductions")[[input$reduction_clustering_method]])) { |
|
4470 |
+ withProgress(message = "Finding clusters", max = 1, value = 1, { |
|
4471 |
+ vals$counts <- seuratFindClusters(inSCE = vals$counts, |
|
4472 |
+ useAssay = "seuratScaledData", |
|
4473 |
+ useReduction = input$reduction_clustering_method, |
|
4474 |
+ dims = input$reduction_clustering_count, |
|
4475 |
+ algorithm = input$algorithm.use, |
|
4476 |
+ groupSingletons = input$group.singletons) |
|
4477 |
+ }) |
|
4478 |
+ updateCollapse(session = session, "SeuratUI", style = list("Clustering" = "danger")) |
|
4479 |
+ showNotification("Find Clusters Complete") |
|
4480 |
+ |
|
4481 |
+ #} else { |
|
4482 |
+ # showNotification("Please compute PCA or ICA before processing clusters.", type = "error") |
|
4483 |
+ #} |
|
4484 |
+ #} else { |
|
4485 |
+ # showNotification("Please normalize, scale, and perform dimensionality reduction on the data before computing UMAP", type = "error") |
|
4486 |
+ #} |
|
4515 | 4487 |
}) |
4516 | 4488 |
|
4517 | 4489 |
#Run tSNE |
4518 | 4490 |
observeEvent(input$run_tsne_button, { |
4519 |
- if (!is.null(vals$counts)) { |
|
4520 |
- if (!is.null(vals$counts@metadata[["seurat"]])) { |
|
4521 |
- if (!is.null(slot(vals$counts@metadata[["seurat"]], "reductions")[[input$reduction_tsne_method]])) { |
|
4491 |
+ req(vals$counts) |
|
4492 |
+# if (!is.null(vals$counts@metadata[["seurat"]])) { |
|
4493 |
+# if (!is.null(slot(vals$counts@metadata[["seurat"]], "reductions")[[input$reduction_tsne_method]])) { |
|
4522 | 4494 |
withProgress(message = "Running tSNE", max = 1, value = 1, { |
4523 |
- vals$counts <- seuratRunTSNE(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, input$reduction_tsne_method, input$reduction_tsne_count) |
|
4495 |
+ vals$counts <- seuratRunTSNE(inSCE = vals$counts, |
|
4496 |
+ useReduction = input$reduction_tsne_method, |
|
4497 |
+ reducedDimName = "seuratTSNE", |
|
4498 |
+ dims = input$reduction_tsne_count) |
|
4524 | 4499 |
}) |
4525 | 4500 |
withProgress(message = "Plotting tSNE", max = 1, value = 1, { |
4526 |
- seuratWorkflow$plotObject$TSNE <- seuratReductionPlot(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, "tsne") |
|
4501 |
+ seuratWorkflow$plotObject$TSNE <- seuratReductionPlot(inSCE = vals$counts, |
|
4502 |
+ useReduction = "tsne") |
|
4527 | 4503 |
}) |
4528 | 4504 |
updateCollapse(session = session, "SeuratUI", style = list("tSNE/UMAP" = "danger")) |
4529 | 4505 |
showNotification("tSNE Complete") |
4530 |
- } |
|
4531 |
- else { |
|
4532 |
- showNotification("Please compute pca/ica before processing tsne!", type = "error") |
|
4533 |
- } |
|
4534 |
- } |
|
4535 |
- } |
|
4536 |
- else { |
|
4537 |
- showNotification("Please input dataset (rds file) before computing tsne!", type = "error") |
|
4538 |
- } |
|
4506 |
+# } else { |
|
4507 |
+# showNotification("Please compute PCA or ICA before runnibg tSNE.", type = "error") |
|
4508 |
+# } |
|
4509 |
+# } |
|
4539 | 4510 |
}) |
4540 | 4511 |
|
4541 | 4512 |
#Run UMAP |
4542 | 4513 |
observeEvent(input$run_umap_button, { |
4543 |
- if (!is.null(vals$counts)) { |
|
4544 |
- if (!is.null(vals$counts@metadata[["seurat"]])) { |
|
4545 |
- if (!is.null(slot(vals$counts@metadata[["seurat"]], "reductions")[[input$reduction_umap_method]])) { |
|
4514 |
+ req(vals$counts) |
|
4515 |
+# if (!is.null(vals$counts@metadata[["seurat"]])) { |
|
4516 |
+# if (!is.null(slot(vals$counts@metadata[["seurat"]], "reductions")[[input$reduction_umap_method]])) { |
|
4546 | 4517 |
withProgress(message = "Running UMAP", max = 1, value = 1, { |
4547 |
- vals$counts <- seuratRunUMAP(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, input$reduction_umap_method, input$reduction_umap_count) |
|
4518 |
+ vals$counts <- seuratRunUMAP(inSCE = vals$counts, |
|
4519 |
+ useReduction = input$reduction_umap_method, |
|
4520 |
+ reducedDimName = "seuratUMAP", |
|
4521 |
+ dims = input$reduction_umap_count) |
|
4548 | 4522 |
}) |
4549 | 4523 |
withProgress(message = "Plotting UMAP", max = 1, value = 1, { |
4550 |
- seuratWorkflow$plotObject$UMAP <- seuratReductionPlot(vals$counts, useAssay = vals$counts@metadata$seuratSelectedAssay, seuratWorkflow$geneNamesSeurat, "umap") |
|
4524 |
+ seuratWorkflow$plotObject$UMAP <- seuratReductionPlot(inSCE = vals$counts, |
|
4525 |
+ useReduction = "umap") |
|
4551 | 4526 |
}) |
4552 | 4527 |
updateCollapse(session = session, "SeuratUI", style = list("tSNE/UMAP" = "danger")) |
4553 | 4528 |
showNotification("UMAP Complete") |
4554 |
- } |
|
4555 |
- else { |
|
4556 |
- showNotification("Please compute pca/ica before processing umap!", type = "error") |
|
4557 |
- } |
|
4558 |
- } |
|
4559 |
- } |
|
4560 |
- else { |
|
4561 |
- showNotification("Please input dataset (rds file) before computing umap!", type = "error") |
|
4562 |
- } |
|
4529 |
+# } else { |
|
4530 |
+# showNotification("Please compute PCA or ICA before running UMAP.", type = "error") |
|
4531 |
+# } |
|
4532 |
+# } |
|
4563 | 4533 |
}) |
4564 | 4534 |
|
4565 | 4535 |
#Display the number of significant PC computed |
... | ... |
@@ -4664,7 +4634,10 @@ shinyServer(function(input, output, session) { |
4664 | 4634 |
#Customize heatmap (pca) with selected options |
4665 | 4635 |
observeEvent(input$plot_heatmap_pca_button, { |
4666 | 4636 |
if (!is.null(input$picker_dimheatmap_components_pca)) { |
4667 |
- seuratWorkflow$plotObject$Heatmap <- seuratHeatmapPlot(seuratWorkflow$plotObject$HeatmapCompute, length(input$picker_dimheatmap_components_pca), input$slider_dimheatmap_pca, input$picker_dimheatmap_components_pca) |
|
4637 |
+ seuratWorkflow$plotObject$Heatmap <- seuratHeatmapPlot(plotObject = seuratWorkflow$plotObject$HeatmapCompute, |
|
4638 |
+ dims = length(input$picker_dimheatmap_components_pca), |
|
4639 |
+ ncol = input$slider_dimheatmap_pca, |
|
4640 |
+ labels = input$picker_dimheatmap_components_pca) |
|
4668 | 4641 |
} |
4669 | 4642 |
}) |
4670 | 4643 |
|
... | ... |
@@ -1,4 +1,4 @@ |
1 |
-exampleDatasets <- c("mouseBrainSubset", "maits") |
|
1 |
+exampleDatasets <- c() ## Need to add final small example data here |
|
2 | 2 |
if ("scRNAseq" %in% rownames(installed.packages())){ |
3 | 3 |
exampleDatasets <- c(exampleDatasets, "fluidigm_pollen_et_al", |
4 | 4 |
"th2_mahata_et_al", "allen_tasic_et_al") |
... | ... |
@@ -34,8 +34,7 @@ shinyPanelUpload <- fluidPage( |
34 | 34 |
|
35 | 35 |
h3("Choose data source:"), |
36 | 36 |
radioButtons("uploadChoice", label = NULL, c("Upload files" = "files", |
37 |
- "Upload SCtkExperiment RDS File" = "rds", |
|
38 |
- "Upload Seurat RDS File" = "rds_seurat", |
|
37 |
+ "Upload SingleCellExperiment or Seurat object stored in an RDS File" = "rds", |
|
39 | 38 |
"Use example data" = "example", |
40 | 39 |
"Import from a preprocessing tool" = 'directory') |
41 | 40 |
), |
... | ... |
@@ -224,7 +224,9 @@ shinyPanelSeurat <- fluidPage( |
224 | 224 |
panel( |
225 | 225 |
selectInput(inputId = "reduction_clustering_method", label = "Select reduction method: ", choices = c("pca", "ica")), |
226 | 226 |
textInput(inputId = "reduction_clustering_count", label = "Select number of reduction components: ", value = "20"), |
227 |
- selectInput(inputId = "algorithm.use", label = "Select model for scaling: ", choices = c("original Louvain algorithm", "Louvain algorithm with multilevel refinement", "SLM algorithm")), |
|
227 |
+ selectInput(inputId = "algorithm.use", label = "Selectclustering algorithm: ", choices = list("Original Louvain algorithm" = "louvain", |
|
228 |
+ "Louvain algorithm with multilevel refinement" = "multilevel", |
|
229 |
+ "SLM algorithm" = "SLM")), |
|
228 | 230 |
materialSwitch(inputId = "group.singletons", label = "Group singletons?", value = TRUE), |
229 | 231 |
actionButton(inputId = "find_clusters_button", "Find Clusters") |
230 | 232 |
) |
231 | 233 |
deleted file mode 100644 |
... | ... |
@@ -1,52 +0,0 @@ |
1 |
-% Generated by roxygen2: do not edit by hand |
|
2 |
-% Please edit documentation in R/miscFunctions.R |
|
3 |
-\name{createSCE} |
|
4 |
-\alias{createSCE} |
|
5 |
-\title{Create a SCtkExperiment object} |
|
6 |
-\usage{ |
|
7 |
-createSCE( |
|
8 |
- assayFile = NULL, |
|
9 |
- annotFile = NULL, |
|
10 |
- featureFile = NULL, |
|
11 |
- assayName = "counts", |
|
12 |
- inputDataFrames = FALSE, |
|
13 |
- createLogCounts = TRUE |
|
14 |
-) |
|
15 |
-} |
|
16 |
-\arguments{ |
|
17 |
-\item{assayFile}{The path to a text file that contains a header row of sample |
|
18 |
-names, and rows of raw counts per gene for those samples.} |
|
19 |
- |
|
20 |
-\item{annotFile}{The path to a text file that contains columns of annotation |
|
21 |
-information for each sample in the assayFile. This file should have the same |
|
22 |
-number of rows as there are columns in the assayFile.} |
|
23 |
- |
|
24 |
-\item{featureFile}{The path to a text file that contains columns of |
|
25 |
-annotation information for each gene in the count matrix. This file should |
|
26 |
-have the same genes in the same order as assayFile. This is optional.} |
|
27 |
- |
|
28 |
-\item{assayName}{The name of the assay that you are uploading. The default |
|
29 |
-is "counts".} |
|
30 |
- |
|
31 |
-\item{inputDataFrames}{If TRUE, assayFile and annotFile are read as data |
|
32 |
-frames instead of file paths. The default is FALSE.} |
|
33 |
- |
|
34 |
-\item{createLogCounts}{If TRUE, create a log2(counts+1) normalized assay |
|
35 |
-and include it in the object. The default is TRUE} |
|
36 |
-} |
|
37 |
-\value{ |
|
38 |
-a SCtkExperiment object |
|
39 |
-} |
|
40 |
-\description{ |
|
41 |
-From a file of counts and a file of annotation information, create a |
|
42 |
-SCtkExperiment object. |
|
43 |
-} |
|
44 |
-\examples{ |
|
45 |
-data("mouseBrainSubsetSCE") |
|
46 |
-counts_mat <- assay(mouseBrainSubsetSCE, "counts") |
|
47 |
-sample_annot <- colData(mouseBrainSubsetSCE) |
|
48 |
-row_annot <- rowData(mouseBrainSubsetSCE) |
|
49 |
-newSCE <- createSCE(assayFile = counts_mat, annotFile = sample_annot, |
|
50 |
- featureFile = row_annot, assayName = "counts", |
|
51 |
- inputDataFrames = TRUE, createLogCounts = TRUE) |
|
52 |
-} |
53 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,21 +0,0 @@ |
1 |
-% Generated by roxygen2: do not edit by hand |
|
2 |
-% Please edit documentation in R/seuratFunctions.R |
|
3 |
-\name{.rdsToSce} |
|
4 |
-\alias{.rdsToSce} |
|
5 |
-\title{.rdsToSce |
|
6 |
-Reads rds file (from a local path) and loads into sce object |
|
7 |
-*Only to be used for first time initialization of the rds file into R environment*} |
|
8 |
-\usage{ |
|
9 |
-.rdsToSce(filePath) |
|
10 |
-} |
|
11 |
-\arguments{ |
|
12 |
-\item{filePath}{path of the rds file to load} |
|
13 |
-} |
|
14 |
-\value{ |
|
15 |
-sce object |
|
16 |
-} |
|
17 |
-\description{ |
|
18 |
-.rdsToSce |
|
19 |
-Reads rds file (from a local path) and loads into sce object |
|
20 |
-*Only to be used for first time initialization of the rds file into R environment* |
|
21 |
-} |
22 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,19 +0,0 @@ |
1 |
-% Generated by roxygen2: do not edit by hand |
|
2 |
-% Please edit documentation in R/seuratFunctions.R |
|
3 |
-\name{.rowNamesSCE} |
|
4 |
-\alias{.rowNamesSCE} |
|
5 |
-\title{.rowNamesSCE |
|
6 |
-Retrieves a list of genenames/rownames/featurenames from sce object} |
|
7 |
-\usage{ |
|
8 |
-.rowNamesSCE(inSCE) |
|
9 |
-} |
|
10 |
-\arguments{ |
|
11 |
-\item{inSCE}{sce object from which the genenames/rownames/featurenames should be extracted} |
|
12 |
-} |
|
13 |
-\value{ |
|
14 |
-list() of genenames/rownames/featurenames |
|
15 |
-} |
|
16 |
-\description{ |
|
17 |
-.rowNamesSCE |
|
18 |
-Retrieves a list of genenames/rownames/featurenames from sce object |
|
19 |
-} |
20 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,19 +0,0 @@ |
1 |
-% Generated by roxygen2: do not edit by hand |
|
2 |
-% Please edit documentation in R/seuratFunctions.R |
|
3 |
-\name{.rowNamesSeurat} |
|
4 |
-\alias{.rowNamesSeurat} |
|
5 |
-\title{.rowNamesSeurat |
|
6 |
-Retrieves a list of genenames/rownames/featurenames from seurat object} |
|
7 |
-\usage{ |
|
8 |
-.rowNamesSeurat(seuratObject) |
|
9 |
-} |
|
10 |
-\arguments{ |
|
11 |
-\item{seuratObject}{seurat object from which the genenames/rownames/featurenames should be extracted} |
|
12 |
-} |
|
13 |
-\value{ |
|
14 |
-list() of genenames/rownames/featurenames |
|
15 |
-} |
|
16 |
-\description{ |
|
17 |
-.rowNamesSeurat |
|
18 |
-Retrieves a list of genenames/rownames/featurenames from seurat object |
|
19 |
-} |
20 | 0 |
deleted file mode 100644 |
... | ... |
@@ -1,21 +0,0 @@ |
1 |
-% Generated by roxygen2: do not edit by hand |
|
2 |
-% Please edit documentation in R/seuratFunctions.R |
|
3 |
-\name{.sceToSeurat} |
|
4 |
-\alias{.sceToSeurat} |
|
5 |
-\title{.sceToSeurat |
|
6 |
-Converts a sce object to seurat object (using rds filepath) |
|
7 |
-*Only to be used for first time initialization of seurat object*} |
|
8 |
-\usage{ |
|
9 |
-.sceToSeurat(filePath) |
|
10 |
-} |
|
11 |
-\arguments{ |
|
12 |
-\item{filePath}{path of the rds file to convert to seurat object} |
|
13 |
-} |
|
14 |
-\value{ |
|
15 |
-seurat object |
|
16 |
-} |
|
17 |
-\description{ |
|
18 |
-.sceToSeurat |
|
19 |
-Converts a sce object to seurat object (using rds filepath) |
|
20 |
-*Only to be used for first time initialization of seurat object* |
|
21 |
-} |
... | ... |
@@ -63,36 +63,3 @@ Run GSVA analysis on a SCtkExperiment object. |
63 | 63 |
Plot GSVA Results |
64 | 64 |
}} |
65 | 65 |
|
66 |
-\examples{ |
|
67 |
-utils::data(maits, package = "MAST") |
|
68 |
-utils::data(c2BroadSets, package = "GSVAdata") |
|
69 |
-maitslogtpm <- t(maits$expressionmat) |
|
70 |
-genesToSubset <- rownames(maitslogtpm)[which(rownames(maitslogtpm) \%in\% |
|
71 |
- GSEABase::geneIds(c2BroadSets[["KEGG_PROTEASOME"]]))] |
|
72 |
-maitslogtpm <- maitslogtpm[rownames(maitslogtpm) \%in\% genesToSubset, ] |
|
73 |
-maitsfeatures <- maits$fdat[rownames(maits$fdat) \%in\% genesToSubset, ] |
|
74 |
-maitsSCE <- createSCE(assayFile = maitslogtpm, annotFile = maits$cdat, |
|
75 |
- featureFile = maitsfeatures, assayName = "logtpm", |
|
76 |
- inputDataFrames = TRUE, createLogCounts = FALSE) |
|
77 |
-rowData(maitsSCE)$testbiomarker <- rep(1, nrow(maitsSCE)) |
|
78 |
-res <- gsvaSCE(inSCE = maitsSCE, useAssay = "logtpm", |
|
79 |
- pathwaySource = "Manual Input", pathwayNames = "testbiomarker", |
|
80 |
- parallel.sz = 1) |
|
81 |
-#Create a small example to run |
|
82 |
-utils::data(maits, package = "MAST") |
|
83 |
-utils::data(c2BroadSets, package = "GSVAdata") |
|
84 |
-maitslogtpm <- t(maits$expressionmat) |
|
85 |
-genesToSubset <- rownames(maitslogtpm)[which(rownames(maitslogtpm) \%in\% |
|
86 |
- GSEABase::geneIds(c2BroadSets[["KEGG_PROTEASOME"]]))] |
|
87 |
-maitslogtpm <- maitslogtpm[rownames(maitslogtpm) \%in\% genesToSubset, ] |
|
88 |
-maitsfeatures <- maits$fdat[rownames(maits$fdat) \%in\% genesToSubset, ] |
|
89 |
-maitsSCE <- createSCE(assayFile = maitslogtpm, annotFile = maits$cdat, |
|
90 |
- featureFile = maitsfeatures, assayName = "logtpm", |
|
91 |
- inputDataFrames = TRUE, createLogCounts = FALSE) |
|
92 |
-rowData(maitsSCE)$testbiomarker <- rep(1, nrow(maitsSCE)) |
|
93 |
-res <- gsvaSCE(inSCE = maitsSCE, useAssay = "logtpm", |
|
94 |
- pathwaySource = "Manual Input", pathwayNames = "testbiomarker", |
|
95 |
- parallel.sz = 1) |
|
96 |
-gsvaPlot(inSCE = maitsSCE, gsvaData = res, |
|
97 |
- plotType = "Violin", condition = "condition") |
|
98 |
-} |
99 | 66 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,50 @@ |
1 |
+% Generated by roxygen2: do not edit by hand |
|
2 |
+% Please edit documentation in R/importFromFiles.R |
|
3 |
+\name{importFromFiles} |
|
4 |
+\alias{importFromFiles} |
|
5 |
+\title{Create a SingleCellExperiment object from files} |
|
6 |
+\usage{ |
|
7 |
+importFromFiles( |
|
8 |
+ assayFile, |
|
9 |
+ annotFile = NULL, |
|
10 |
+ featureFile = NULL, |
|
11 |
+ assayName = "counts", |
|
12 |
+ inputDataFrames = FALSE, |
|
13 |
+ class = c("Matrix", "matrix"), |
|
14 |
+ delayedArray = FALSE |
|
15 |
+) |
|
16 |
+} |
|
17 |
+\arguments{ |
|
18 |
+\item{assayFile}{The path to a file in .mtx, .txt, .csv, .tab, or .tsv format.} |
|
19 |
+ |
|
20 |
+\item{annotFile}{The path to a text file that contains columns of annotation |
|
21 |
+information for each sample in the assayFile. This file should have the same |
|
22 |
+number of rows as there are columns in the assayFile. If multiple samples are |
|
23 |
+represented in these files, this should be denoted by a column called \code{'sample'} |
|
24 |
+within the \code{annotFile}.} |
|
25 |
+ |
|
26 |
+\item{featureFile}{The path to a text file that contains columns of |
|
27 |
+annotation information for each gene in the count matrix. This file should |
|
28 |
+have the same genes in the same order as assayFile. This is optional.} |
|
29 |
+ |
|
30 |
+\item{assayName}{The name of the assay that you are uploading. The default |
|
31 |
+is "counts".} |
|
32 |
+ |
|
33 |
+\item{inputDataFrames}{If TRUE, assayFile and annotFile are read as data |
|
34 |
+frames instead of file paths. The default is FALSE.} |
|
35 |
+ |
|
36 |
+\item{class}{Character. The class of the expression matrix stored in the SCE |
|
37 |
+object. Can be one of "Matrix" (as returned by |
|
38 |
+\link[Matrix]{readMM} function), or "matrix" (as returned by |
|
39 |
+\link[base]{matrix} function). Default "Matrix".} |
|
40 |
+ |
|
41 |
+\item{delayedArray}{Boolean. Whether to read the expression matrix as |
|
42 |
+\link[DelayedArray]{DelayedArray} object or not. Default \code{TRUE}.} |
|
43 |
+} |
|
44 |
+\value{ |
|
45 |
+a SingleCellExperiment object |
|
46 |
+} |
|
47 |
+\description{ |
|
48 |
+Creates a SingleCellExperiment object from a counts file in various formats. |
|
49 |
+and a file of annotation information, . |
|
50 |
+} |
... | ... |
@@ -4,12 +4,13 @@ |
4 | 4 |
\alias{summarizeSCE} |
5 | 5 |
\title{Summarize SCtkExperiment} |
6 | 6 |
\usage{ |
7 |
-summarizeSCE(inSCE, useAssay = "counts", sampleVariableName = NULL) |
|
7 |
+summarizeSCE(inSCE, useAssay = NULL, sampleVariableName = NULL) |
|
8 | 8 |
} |
9 | 9 |
\arguments{ |
10 |
-\item{inSCE}{Input SCtkExperiment object.} |
|
10 |
+\item{inSCE}{Input SingleCellExperiment object.} |
|
11 | 11 |
|
12 |
-\item{useAssay}{Indicate which assay to summarize. Default \code{"counts"}.} |
|
12 |
+\item{useAssay}{Indicate which assay to summarize. If \code{NULL}, then the first |
|
13 |
+assay in \code{inSCE} will be used. Default \code{NULL}.} |
|
13 | 14 |
|
14 | 15 |
\item{sampleVariableName}{Variable name in \code{colData} denoting which |
15 | 16 |
sample each cell belongs to. If \code{NULL}, all cells will be assumed |
... | ... |
@@ -1,15 +1,5 @@ |
1 | 1 |
context("misc functions") |
2 | 2 |
|
3 |
-test_that("Create SCTKE", { |
|
4 |
- expect_is(createSCE(assayFile = assay(mouseBrainSubsetSCE[1:100, ]), |
|
5 |
- inputDataFrames = TRUE), |
|
6 |
- "SCtkExperiment") |
|
7 |
- expect_error(createSCE(assayFile = assay(mouseBrainSubsetSCE[1:100, ]), |
|
8 |
- annotFile = colData(mouseBrainSubsetSCE)[1:10, ], |
|
9 |
- inputDataFrames = TRUE), |
|
10 |
- "Different number of samples in input matrix and annotations: annot: 10, counts: 30") |
|
11 |
-}) |
|
12 |
- |
|
13 | 3 |
test_that("summarizeSCE", { |
14 | 4 |
ta <- summarizeSCE(mouseBrainSubsetSCE, sample = NULL) |
15 | 5 |
expect_is(ta, "data.frame") |