Skip to content

Commit

Permalink
1.1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
GEHoffman committed Feb 13, 2024
1 parent 9fa8203 commit 8019df8
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 27 deletions.
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

# dreamlet 1.1.17
- bug fix in `plotPCA()`
- new functionality in `plotPCA()` and `outlierByAssay()`
- works on any `list`, not just `dreamletProcessedData`
- allows outlier analysis on residuals

# dreamlet 1.1.16
- Feb 8, 2024
Expand Down
1 change: 1 addition & 0 deletions R/dreamletProcessedData.R
Original file line number Diff line number Diff line change
Expand Up @@ -448,3 +448,4 @@ setMethod(
list(assayLevel = df, geneLevel = df2)
}
)

9 changes: 7 additions & 2 deletions R/outlier.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,16 @@ outlier <- function(data, robust = FALSE, ...) {
#' @export
outlierByAssay = function(object, assays = assayNames(object), nPC=2, robust = FALSE, ...){

stopifnot(is(object, "dreamletProcessedData"))
stopifnot(is(object, "list"))

df = lapply(assays, function(id){
# get normalized expression
Y <- assay(object, id)$E
# Y <- assay(object, id)$E
if( is(object[[id]], "EList") ){
Y <- object[[id]]$E
}else{
Y <- object[[id]]
}

# PCA
# dcmp <- prcomp(scale(t(Y)))
Expand Down
30 changes: 25 additions & 5 deletions R/plotPCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ setGeneric("plotPCA", BiocGenerics::plotPCA)
#'
#' Compute PCA of gene expression for an assay, and plot samples coloring by outlier score
#'
#' @param object \code{dreamletProcessedData} from \code{processAssays()}
#' @param object \code{dreamletProcessedData} from \code{processAssays()} or a \code{list} from \code{residuals()}
#' @param assays assays / cell types to analyze
#' @param nPC number of PCs to uses for outlier score with \code{outlier()}
#' @param robust use robust covariance method, defaults to \code{FALSE}
Expand All @@ -20,7 +20,7 @@ setGeneric("plotPCA", BiocGenerics::plotPCA)
#'
#' @name plotPCA
#' @rdname plotPCA
#' @aliases plotPCA plotPCA,dreamletProcessedData-method
#' @aliases plotPCA plotPCA,list-method
#' @examples
#' library(muscat)
#' library(SingleCellExperiment)
Expand All @@ -39,13 +39,26 @@ setGeneric("plotPCA", BiocGenerics::plotPCA)
#' res.proc <- processAssays(pb, ~group_id)
#'
#' # PCA to identify outliers
#' plotPCA( res.proc, "CD14+ Monocytes")
#' # from normalized expression
#' plotPCA( res.proc, c("B cells", "CD14+ Monocytes"))
#'
#' # Run on regression residuals
#' #-----------------------------
#'
#' # Regression analysis
#' fit = dreamlet(res.proc, ~ group_id)
#'
#' # Extract regression residuals
#' residsObj = residuals(fit)
#'
#' # PCA on residuals
#' plotPCA( residsObj, c("B cells", "CD14+ Monocytes"))
#
#' @seealso \code{outlierByAssay()}
#' @export
setMethod("plotPCA", signature(object="dreamletProcessedData"), function(object, assays = assayNames(object), nPC=2, robust = FALSE, ..., maxOutlierZ=20, nrow=2, size=2, fdr.cutoff=0.05){
setMethod("plotPCA", signature(object="list"), function(object, assays = names(object), nPC=2, robust = FALSE, ..., maxOutlierZ=20, nrow=2, size=2, fdr.cutoff=0.05){

stopifnot(all(assays %in% assayNames(object)))
stopifnot(all(assays %in% names(object)))

PC1 <- PC2 <- z <- pValue <- FDR <- NULL

Expand All @@ -64,3 +77,10 @@ setMethod("plotPCA", signature(object="dreamletProcessedData"), function(object,
})









2 changes: 1 addition & 1 deletion docs/404.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/authors.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion docs/news/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified docs/reference/Rplot001.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/reference/Rplot002.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/reference/index.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified docs/reference/plotPCA-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/reference/plotPCA-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 33 additions & 9 deletions docs/reference/plotPCA.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 18 additions & 5 deletions man/plotPCA.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8019df8

Please sign in to comment.