... | ... |
@@ -6,7 +6,7 @@ |
6 | 6 |
\usage{ |
7 | 7 |
runHarmony( |
8 | 8 |
inSCE, |
9 |
- useAssay = "logcounts", |
|
9 |
+ useAssay = NULL, |
|
10 | 10 |
useReducedDim = NULL, |
11 | 11 |
batch = "batch", |
12 | 12 |
reducedDimName = "HARMONY", |
... | ... |
@@ -24,10 +24,13 @@ runHarmony( |
24 | 24 |
\item{inSCE}{Input \linkS4class{SingleCellExperiment} object} |
25 | 25 |
|
26 | 26 |
\item{useAssay}{A single character indicating the name of the assay requiring |
27 |
-batch correction. Default \code{"logcounts"}.} |
|
27 |
+batch correction. Default \code{NULL}. It is recommended to use a reducedDim |
|
28 |
+such as PCA through the `useReducedDim` parameter of this function.} |
|
28 | 29 |
|
29 | 30 |
\item{useReducedDim}{A single character indicating the name of the reducedDim |
30 |
-used to be corrected. Specifying this will ignore \code{useAssay}. Default |
|
31 |
+to be used. It is recommended to use a reducedDim instead of a full assay as |
|
32 |
+using an assay might cause the algorithm to not converge and throw error. |
|
33 |
+Specifying this will ignore \code{useAssay}. Default |
|
31 | 34 |
\code{NULL}.} |
32 | 35 |
|
33 | 36 |
\item{batch}{A single character indicating a field in \code{colData} that |
... | ... |
@@ -56,12 +56,12 @@ make soft kmeans cluster approach hard clustering. Default \code{0.1}.} |
56 | 56 |
\item{nIter}{An integer. The max number of iterations to perform. Default |
57 | 57 |
\code{10L}.} |
58 | 58 |
|
59 |
+\item{seed}{Set seed for reproducibility. Default is \code{12345}.} |
|
60 |
+ |
|
59 | 61 |
\item{verbose}{Whether to print progress messages. Default \code{TRUE}.} |
60 | 62 |
|
61 | 63 |
\item{...}{Other arguments passed to \code{\link[harmony]{HarmonyMatrix}}. |
62 | 64 |
See details.} |
63 |
- |
|
64 |
-\item{Set}{seed for reproducibility. Default is \code{12345}.} |
|
65 | 65 |
} |
66 | 66 |
\value{ |
67 | 67 |
The input \linkS4class{SingleCellExperiment} object with |
... | ... |
@@ -15,6 +15,7 @@ runHarmony( |
15 | 15 |
theta = 5, |
16 | 16 |
sigma = 0.1, |
17 | 17 |
nIter = 10, |
18 |
+ seed = 12345, |
|
18 | 19 |
verbose = TRUE, |
19 | 20 |
... |
20 | 21 |
) |
... | ... |
@@ -59,6 +60,8 @@ make soft kmeans cluster approach hard clustering. Default \code{0.1}.} |
59 | 60 |
|
60 | 61 |
\item{...}{Other arguments passed to \code{\link[harmony]{HarmonyMatrix}}. |
61 | 62 |
See details.} |
63 |
+ |
|
64 |
+\item{Set}{seed for reproducibility. Default is \code{12345}.} |
|
62 | 65 |
} |
63 | 66 |
\value{ |
64 | 67 |
The input \linkS4class{SingleCellExperiment} object with |
... | ... |
@@ -79,9 +79,11 @@ work with only include: \code{nclust}, \code{tau}, \code{block.size}, |
79 | 79 |
\examples{ |
80 | 80 |
data('sceBatches', package = 'singleCellTK') |
81 | 81 |
logcounts(sceBatches) <- log1p(counts(sceBatches)) |
82 |
+\dontrun{ |
|
82 | 83 |
if (require("harmony")) |
83 | 84 |
sceCorr <- runHarmony(sceBatches) |
84 | 85 |
} |
86 |
+} |
|
85 | 87 |
\references{ |
86 | 88 |
Ilya Korsunsky, et al., 2019 |
87 | 89 |
} |
... | ... |
@@ -79,7 +79,8 @@ work with only include: \code{nclust}, \code{tau}, \code{block.size}, |
79 | 79 |
\examples{ |
80 | 80 |
data('sceBatches', package = 'singleCellTK') |
81 | 81 |
logcounts(sceBatches) <- log1p(counts(sceBatches)) |
82 |
-sceCorr <- runHarmony(sceBatches) |
|
82 |
+if (require("harmony")) |
|
83 |
+ sceCorr <- runHarmony(sceBatches) |
|
83 | 84 |
} |
84 | 85 |
\references{ |
85 | 86 |
Ilya Korsunsky, et al., 2019 |
... | ... |
@@ -20,7 +20,7 @@ runHarmony( |
20 | 20 |
) |
21 | 21 |
} |
22 | 22 |
\arguments{ |
23 |
-\item{inSCE}{Input \linkS4class{SingleCellExperiment} inherited object.} |
|
23 |
+\item{inSCE}{Input \linkS4class{SingleCellExperiment} object} |
|
24 | 24 |
|
25 | 25 |
\item{useAssay}{A single character indicating the name of the assay requiring |
26 | 26 |
batch correction. Default \code{"logcounts"}.} |
... | ... |
@@ -29,9 +29,9 @@ batch correction. Default \code{"logcounts"}.} |
29 | 29 |
used to be corrected. Specifying this will ignore \code{useAssay}. Default |
30 | 30 |
\code{NULL}.} |
31 | 31 |
|
32 |
-\item{batch}{A single character indicating a field in |
|
33 |
-\code{\link{colData}} that annotates the batches. |
|
34 |
-Default \code{"batch"}.} |
|
32 |
+\item{batch}{A single character indicating a field in \code{colData} that |
|
33 |
+annotates the batches of each cell; or a vector/factor with the same length |
|
34 |
+as the number of cells. Default \code{"batch"}.} |
|
35 | 35 |
|
36 | 36 |
\item{reducedDimName}{A single character. The name for the corrected |
37 | 37 |
low-dimensional representation. Will be saved to \code{reducedDim(inSCE)}. |
... | ... |
@@ -78,7 +78,7 @@ work with only include: \code{nclust}, \code{tau}, \code{block.size}, |
78 | 78 |
} |
79 | 79 |
\examples{ |
80 | 80 |
data('sceBatches', package = 'singleCellTK') |
81 |
-logcounts(sceBatches) <- log(counts(sceBatches) + 1) |
|
81 |
+logcounts(sceBatches) <- log1p(counts(sceBatches)) |
|
82 | 82 |
sceCorr <- runHarmony(sceBatches) |
83 | 83 |
} |
84 | 84 |
\references{ |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,86 @@ |
1 |
+% Generated by roxygen2: do not edit by hand |
|
2 |
+% Please edit documentation in R/runBatchCorrection.R |
|
3 |
+\name{runHarmony} |
|
4 |
+\alias{runHarmony} |
|
5 |
+\title{Apply Harmony batch effect correction method to SingleCellExperiment object} |
|
6 |
+\usage{ |
|
7 |
+runHarmony( |
|
8 |
+ inSCE, |
|
9 |
+ useAssay = "logcounts", |
|
10 |
+ useReducedDim = NULL, |
|
11 |
+ batch = "batch", |
|
12 |
+ reducedDimName = "HARMONY", |
|
13 |
+ nComponents = 50, |
|
14 |
+ lambda = 0.1, |
|
15 |
+ theta = 5, |
|
16 |
+ sigma = 0.1, |
|
17 |
+ nIter = 10, |
|
18 |
+ verbose = TRUE, |
|
19 |
+ ... |
|
20 |
+) |
|
21 |
+} |
|
22 |
+\arguments{ |
|
23 |
+\item{inSCE}{Input \linkS4class{SingleCellExperiment} inherited object.} |
|
24 |
+ |
|
25 |
+\item{useAssay}{A single character indicating the name of the assay requiring |
|
26 |
+batch correction. Default \code{"logcounts"}.} |
|
27 |
+ |
|
28 |
+\item{useReducedDim}{A single character indicating the name of the reducedDim |
|
29 |
+used to be corrected. Specifying this will ignore \code{useAssay}. Default |
|
30 |
+\code{NULL}.} |
|
31 |
+ |
|
32 |
+\item{batch}{A single character indicating a field in |
|
33 |
+\code{\link{colData}} that annotates the batches. |
|
34 |
+Default \code{"batch"}.} |
|
35 |
+ |
|
36 |
+\item{reducedDimName}{A single character. The name for the corrected |
|
37 |
+low-dimensional representation. Will be saved to \code{reducedDim(inSCE)}. |
|
38 |
+Default \code{"HARMONY"}.} |
|
39 |
+ |
|
40 |
+\item{nComponents}{An integer. The number of PCs to use and generate. |
|
41 |
+Default \code{50L}.} |
|
42 |
+ |
|
43 |
+\item{lambda}{A Numeric scalar. Ridge regression penalty parameter. Must be |
|
44 |
+strictly positive. Smaller values result in more aggressive correction. |
|
45 |
+Default \code{0.1}.} |
|
46 |
+ |
|
47 |
+\item{theta}{A Numeric scalar. Diversity clustering penalty parameter. Larger |
|
48 |
+values of theta result in more diverse clusters. theta=0 does not encourage |
|
49 |
+any diversity. Default \code{5}.} |
|
50 |
+ |
|
51 |
+\item{sigma}{A Numeric scalar. Width of soft kmeans clusters. Larger values |
|
52 |
+of sigma result in cells assigned to more clusters. Smaller values of sigma |
|
53 |
+make soft kmeans cluster approach hard clustering. Default \code{0.1}.} |
|
54 |
+ |
|
55 |
+\item{nIter}{An integer. The max number of iterations to perform. Default |
|
56 |
+\code{10L}.} |
|
57 |
+ |
|
58 |
+\item{verbose}{Whether to print progress messages. Default \code{TRUE}.} |
|
59 |
+ |
|
60 |
+\item{...}{Other arguments passed to \code{\link[harmony]{HarmonyMatrix}}. |
|
61 |
+See details.} |
|
62 |
+} |
|
63 |
+\value{ |
|
64 |
+The input \linkS4class{SingleCellExperiment} object with |
|
65 |
+\code{reducedDim(inSCE, reducedDimName)} updated. |
|
66 |
+} |
|
67 |
+\description{ |
|
68 |
+Harmony is an algorithm that projects cells into a shared |
|
69 |
+embedding in which cells group by cell type rather than dataset-specific |
|
70 |
+conditions. |
|
71 |
+} |
|
72 |
+\details{ |
|
73 |
+Since some of the arguments of \code{\link[harmony]{HarmonyMatrix}} |
|
74 |
+is controlled by this wrapper function. The additional arguments users can |
|
75 |
+work with only include: \code{nclust}, \code{tau}, \code{block.size}, |
|
76 |
+\code{max.iter.cluster}, \code{epsilon.cluster}, \code{epsilon.harmony}, |
|
77 |
+\code{plot_convergence}, \code{reference_values} and \code{cluster_prior}. |
|
78 |
+} |
|
79 |
+\examples{ |
|
80 |
+data('sceBatches', package = 'singleCellTK') |
|
81 |
+logcounts(sceBatches) <- log(counts(sceBatches) + 1) |
|
82 |
+sceCorr <- runHarmony(sceBatches) |
|
83 |
+} |
|
84 |
+\references{ |
|
85 |
+Ilya Korsunsky, et al., 2019 |
|
86 |
+} |
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,61 +0,0 @@ |
1 |
-% Generated by roxygen2: do not edit by hand |
|
2 |
-% Please edit documentation in R/runBatchCorrection.R |
|
3 |
-\name{runHarmony} |
|
4 |
-\alias{runHarmony} |
|
5 |
-\title{Apply Harmony batch effect correction method to SingleCellExperiment object} |
|
6 |
-\usage{ |
|
7 |
-runHarmony( |
|
8 |
- inSCE, |
|
9 |
- useAssay = "logcounts", |
|
10 |
- pcInput = FALSE, |
|
11 |
- batch = "batch", |
|
12 |
- reducedDimName = "HARMONY", |
|
13 |
- nComponents = 50L, |
|
14 |
- theta = 5, |
|
15 |
- nIter = 10L |
|
16 |
-) |
|
17 |
-} |
|
18 |
-\arguments{ |
|
19 |
-\item{inSCE}{\linkS4class{SingleCellExperiment} inherited object. Required.} |
|
20 |
- |
|
21 |
-\item{useAssay}{A single character indicating the name of the assay requiring |
|
22 |
-batch correction. Default \code{"logcounts"}.} |
|
23 |
- |
|
24 |
-\item{pcInput}{A logical scalar. Whether to use a low-dimension matrix for |
|
25 |
-batch effect correction. If \code{TRUE}, \code{useAssay} will be searched |
|
26 |
-from \code{reducedDimNames(inSCE)}. Default \code{FALSE}.} |
|
27 |
- |
|
28 |
-\item{batch}{A single character indicating a field in |
|
29 |
-\code{\link[SummarizedExperiment]{colData}} that annotates the batches. |
|
30 |
-Default \code{"batch"}.} |
|
31 |
- |
|
32 |
-\item{reducedDimName}{A single character. The name for the corrected |
|
33 |
-low-dimensional representation. Will be saved to \code{reducedDim(inSCE)}. |
|
34 |
-Default \code{"HARMONY"}.} |
|
35 |
- |
|
36 |
-\item{nComponents}{An integer. The number of principle components or |
|
37 |
-dimensionality to generate in the resulting matrix. If \code{pcInput} is set |
|
38 |
-to \code{TRUE}, the output dimension will follow the low-dimension matrix, |
|
39 |
-so this argument will be ignored. Default \code{50L}.} |
|
40 |
- |
|
41 |
-\item{theta}{A Numeric scalar. Diversity clustering penalty parameter, |
|
42 |
-Larger value results in more diverse clusters. Default \code{5}} |
|
43 |
- |
|
44 |
-\item{nIter}{An integer. The max number of iterations to perform. Default |
|
45 |
-\code{10L}.} |
|
46 |
-} |
|
47 |
-\value{ |
|
48 |
-The input \linkS4class{SingleCellExperiment} object with |
|
49 |
-\code{reducedDim(inSCE, reducedDimName)} updated. |
|
50 |
-} |
|
51 |
-\description{ |
|
52 |
-Harmony is an algorithm that projects cells into a shared embedding in which |
|
53 |
-cells group by cell type rather than dataset-specific conditions. |
|
54 |
-} |
|
55 |
-\examples{ |
|
56 |
-data('sceBatches', package = 'singleCellTK') |
|
57 |
-sceCorr <- runHarmony(sceBatches, nComponents = 10L) |
|
58 |
-} |
|
59 |
-\references{ |
|
60 |
-Ilya Korsunsky, et al., 2019 |
|
61 |
-} |
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
% Generated by roxygen2: do not edit by hand |
2 |
-% Please edit documentation in R/runHarmony.R |
|
2 |
+% Please edit documentation in R/runBatchCorrection.R |
|
3 | 3 |
\name{runHarmony} |
4 | 4 |
\alias{runHarmony} |
5 | 5 |
\title{Apply Harmony batch effect correction method to SingleCellExperiment object} |
... | ... |
@@ -6,9 +6,9 @@ |
6 | 6 |
\usage{ |
7 | 7 |
runHarmony( |
8 | 8 |
inSCE, |
9 |
- exprs = "logcounts", |
|
9 |
+ useAssay = "logcounts", |
|
10 | 10 |
pcInput = FALSE, |
11 |
- batchKey = "batch", |
|
11 |
+ batch = "batch", |
|
12 | 12 |
reducedDimName = "HARMONY", |
13 | 13 |
nComponents = 50, |
14 | 14 |
theta = 5, |
... | ... |
@@ -19,14 +19,14 @@ runHarmony( |
19 | 19 |
\item{inSCE}{SingleCellExperiment object. An object that stores your dataset |
20 | 20 |
and analysis procedures.} |
21 | 21 |
|
22 |
-\item{exprs}{character, default `"logcounts"`. A string indicating the name |
|
22 |
+\item{useAssay}{character, default `"logcounts"`. A string indicating the name |
|
23 | 23 |
of the assay requiring batch correction in "inSCE", should exist in |
24 | 24 |
`assayNames(inSCE)`.} |
25 | 25 |
|
26 | 26 |
\item{pcInput}{bool, default `FALSE`. Whether to do correction on a low-dim |
27 |
-matrix. If `TRUE`, will look for `exprs` in `reducedDim(inSCE)`.} |
|
27 |
+matrix. If `TRUE`, will look for `useAssay` in `reducedDim(inSCE)`.} |
|
28 | 28 |
|
29 |
-\item{batchKey}{character, default `"batch"`. A string indicating the |
|
29 |
+\item{batch}{character, default `"batch"`. A string indicating the |
|
30 | 30 |
field of `colData(inSCE)` that defines different batches.} |
31 | 31 |
|
32 | 32 |
\item{reducedDimName}{character, default `"HARMONY"`. The name for the |
... | ... |
@@ -52,17 +52,6 @@ cells group by cell type rather than dataset-specific conditions. |
52 | 52 |
\examples{ |
53 | 53 |
|
54 | 54 |
data('sceBatches', package = 'singleCellTK') |
55 |
-sceBatches |
|
56 |
-## class: SingleCellExperiment |
|
57 |
-## dim: 27610 1820 |
|
58 |
-## metadata(0): |
|
59 |
-## assays(3): normcounts logcounts |
|
60 |
-## rownames(27610): GCG MALAT1 ... LOC102724004 LOC102724238 |
|
61 |
-## rowData names(0): |
|
62 |
-## colnames(1820): reads.12732 reads.12733 ... Sample_1598 Sample_1600 |
|
63 |
-## colData names(2): cell_type1 batch |
|
64 |
-## reducedDimNames(5): PCA |
|
65 |
-## spikeNames(0): |
|
66 | 55 |
sceCorr <- runHarmony(sceBatches, nComponents = 10) |
67 | 56 |
} |
68 | 57 |
\references{ |
... | ... |
@@ -4,9 +4,16 @@ |
4 | 4 |
\alias{runHarmony} |
5 | 5 |
\title{Apply Harmony batch effect correction method to SingleCellExperiment object} |
6 | 6 |
\usage{ |
7 |
-runHarmony(inSCE, exprs = "logcounts", pcInput = FALSE, |
|
8 |
- batchKey = "batch", reducedDimName = "HARMONY", nComponents = 50, |
|
9 |
- theta = 5, nIter = 10) |
|
7 |
+runHarmony( |
|
8 |
+ inSCE, |
|
9 |
+ exprs = "logcounts", |
|
10 |
+ pcInput = FALSE, |
|
11 |
+ batchKey = "batch", |
|
12 |
+ reducedDimName = "HARMONY", |
|
13 |
+ nComponents = 50, |
|
14 |
+ theta = 5, |
|
15 |
+ nIter = 10 |
|
16 |
+) |
|
10 | 17 |
} |
11 | 18 |
\arguments{ |
12 | 19 |
\item{inSCE}{SingleCellExperiment object. An object that stores your dataset |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,63 @@ |
1 |
+% Generated by roxygen2: do not edit by hand |
|
2 |
+% Please edit documentation in R/runHarmony.R |
|
3 |
+\name{runHarmony} |
|
4 |
+\alias{runHarmony} |
|
5 |
+\title{Apply Harmony batch effect correction method to SingleCellExperiment object} |
|
6 |
+\usage{ |
|
7 |
+runHarmony(inSCE, exprs = "logcounts", pcInput = FALSE, |
|
8 |
+ batchKey = "batch", reducedDimName = "HARMONY", nComponents = 50, |
|
9 |
+ theta = 5, nIter = 10) |
|
10 |
+} |
|
11 |
+\arguments{ |
|
12 |
+\item{inSCE}{SingleCellExperiment object. An object that stores your dataset |
|
13 |
+and analysis procedures.} |
|
14 |
+ |
|
15 |
+\item{exprs}{character, default `"logcounts"`. A string indicating the name |
|
16 |
+of the assay requiring batch correction in "inSCE", should exist in |
|
17 |
+`assayNames(inSCE)`.} |
|
18 |
+ |
|
19 |
+\item{pcInput}{bool, default `FALSE`. Whether to do correction on a low-dim |
|
20 |
+matrix. If `TRUE`, will look for `exprs` in `reducedDim(inSCE)`.} |
|
21 |
+ |
|
22 |
+\item{batchKey}{character, default `"batch"`. A string indicating the |
|
23 |
+field of `colData(inSCE)` that defines different batches.} |
|
24 |
+ |
|
25 |
+\item{reducedDimName}{character, default `"HARMONY"`. The name for the |
|
26 |
+corrected low-dimensional representation.} |
|
27 |
+ |
|
28 |
+\item{nComponents}{integer, default `20`. Number of principle components or |
|
29 |
+dimensionality to generate in the resulting reducedDim. If `pcInput`, will |
|
30 |
+directly follow the dimensionality of the specified reducedDim.} |
|
31 |
+ |
|
32 |
+\item{theta}{Numeric, default 5. Diversity clustering penalty parameter, |
|
33 |
+Larger value results in more diverse clusters.} |
|
34 |
+ |
|
35 |
+\item{nIter}{integer, default `10`. The max number of iterations to perform.} |
|
36 |
+} |
|
37 |
+\value{ |
|
38 |
+SingleCellExperiment object with `reducedDim(inSCE, reducedDimName)` |
|
39 |
+updated with corrected low-dimentional representation. |
|
40 |
+} |
|
41 |
+\description{ |
|
42 |
+Harmony is an algorithm that projects cells into a shared embedding in which |
|
43 |
+cells group by cell type rather than dataset-specific conditions. |
|
44 |
+} |
|
45 |
+\examples{ |
|
46 |
+ |
|
47 |
+data('sceBatches', package = 'singleCellTK') |
|
48 |
+sceBatches |
|
49 |
+## class: SingleCellExperiment |
|
50 |
+## dim: 27610 1820 |
|
51 |
+## metadata(0): |
|
52 |
+## assays(3): normcounts logcounts |
|
53 |
+## rownames(27610): GCG MALAT1 ... LOC102724004 LOC102724238 |
|
54 |
+## rowData names(0): |
|
55 |
+## colnames(1820): reads.12732 reads.12733 ... Sample_1598 Sample_1600 |
|
56 |
+## colData names(2): cell_type1 batch |
|
57 |
+## reducedDimNames(5): PCA |
|
58 |
+## spikeNames(0): |
|
59 |
+sceCorr <- runHarmony(sceBatches, nComponents = 10) |
|
60 |
+} |
|
61 |
+\references{ |
|
62 |
+Ilya Korsunsky, et al., 2019 |
|
63 |
+} |