Skip to content

Commit

Permalink
Merge pull request #399 from joshua-d-campbell/devel
Browse files Browse the repository at this point in the history
Removed multipanelfigure
  • Loading branch information
joshua-d-campbell authored Nov 5, 2023
2 parents eacaa08 + f979631 commit df08939
Show file tree
Hide file tree
Showing 166 changed files with 806 additions and 751 deletions.
1 change: 1 addition & 0 deletions .github/workflows/BioC-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
with:
extra-packages: |
any::rcmdcheck
url::https://cran.r-project.org/src/contrib/Archive/dbplyr/dbplyr_2.3.4.tar.gz
- name: Install XQuartz on macOS
if: runner.os == 'macOS'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/check-standard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ jobs:
extra-packages: |
any::rcmdcheck
any::tinytex
url::https://cran.r-project.org/src/contrib/Archive/dbplyr/dbplyr_2.3.4.tar.gz
- uses: r-lib/actions/setup-tinytex@v2
- uses: r-lib/actions/check-r-package@v2
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: celda
Title: CEllular Latent Dirichlet Allocation
Version: 1.14.2
Version: 1.18.1
Authors@R: c(person("Joshua", "Campbell", email = "[email protected]",
role = c("aut", "cre")),
person("Shiyi", "Yang", email="[email protected]", role = c("aut")),
Expand All @@ -22,7 +22,7 @@ Imports: plyr, foreach, ggplot2, RColorBrewer, grid, scales, gtable,
Rcpp, RcppEigen, uwot, enrichR, SummarizedExperiment,
MCMCprecision, ggrepel, Rtsne, withr,
scater (>= 1.14.4), scran, dbscan,
DelayedArray, stringr, ComplexHeatmap, multipanelfigure,
DelayedArray, stringr, ComplexHeatmap, gridExtra,
circlize
Suggests: testthat, knitr, roxygen2, rmarkdown, biomaRt, covr,
BiocManager, BiocStyle, TENxPBMCData, singleCellTK, M3DExampleData
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ importFrom(matrixStats,logSumExp)
importFrom(methods,.hasSlot)
importFrom(methods,is)
importFrom(methods,new)
importFrom(multipanelfigure,multi_panel_figure)
importFrom(plyr,mapvalues)
importFrom(reshape2,melt)
importFrom(scales,brewer_pal)
Expand Down
71 changes: 32 additions & 39 deletions R/moduleHeatmap.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#' ordered from those with the lowest probability of the module on the left to
#' the highest probability on the right. Features are ordered from those
#' with the highest probability in the module
#' on the top to the lowest probability on the bottom. Use of
#' \link[multipanelfigure]{save_multi_panel_figure} is recommended for
#' outputting figures in various formats.
#' on the top to the lowest probability on the bottom.
#' @param x A numeric \link{matrix} of counts or a
#' \linkS4class{SingleCellExperiment}
#' with the matrix located in the assay slot under \code{useAssay}.
Expand All @@ -20,7 +18,7 @@
#' Multiple modules can be included in a vector. Default \code{NULL} which
#' plots all module heatmaps.
#' @param featureModule Same as \code{modules}. Either can be used to specify
#' the modules to display.
#' the modules to display.
#' @param col Passed to \link[ComplexHeatmap]{Heatmap}. Set color boundaries
#' and colors.
#' @param topCells Integer. Number of cells with the highest and lowest
Expand Down Expand Up @@ -89,11 +87,11 @@
#' vector of the same length as \code{featureModule}. Default "auto", which
#' automatically pulls module labels from \code{x}.
#' @param moduleLabelSize Passed to \link{gpar}. The size of text (in points).
#' @param width Passed to \link[multipanelfigure]{multi_panel_figure}. The
#' width of the output figure.
#' @param height Passed to \link[multipanelfigure]{multi_panel_figure}. The
#' height of the output figure.
#' @param unit Passed to \link[multipanelfigure]{multi_panel_figure}. Single
#' @param byrow Passed to \link{matrix}. logical. If \code{FALSE} (the default)
#' the figure panel is filled by columns, otherwise the figure panel is filled
#' by rows.
#' @param top Passed to \link[gridExtra]{marrangeGrob}. The title for each page.
#' @param unit Passed to \link[grid]{unit}. Single
#' character object defining the unit of all dimensions defined.
#' @param ncol Integer. Number of columns of module heatmaps. If \code{NULL},
#' then this will be automatically calculated so that the number of columns
Expand All @@ -103,20 +101,19 @@
#' then rasterization will be automatically determined by the underlying
#' \link[ComplexHeatmap]{Heatmap} function. Default \code{TRUE}.
#' @param returnAsList Boolean. If \code{TRUE}, then a list of plots will be
#' returned instead of a single multi-panel figure. These plots can be
#' returned instead of a single multi-panel figure. These plots can be
#' displayed using the \link[grid]{grid.draw} function. Default \code{FALSE}.
#' @param ... Additional parameters passed to \link[ComplexHeatmap]{Heatmap}.
#' @return A \link[multipanelfigure]{multi_panel_figure} object if plotting
#' @return A list object if plotting
#' more than one module heatmaps. Otherwise a
#' \link[ComplexHeatmap]{HeatmapList} object is returned.
#' @importFrom methods .hasSlot
#' @importFrom multipanelfigure multi_panel_figure
#' @export
setGeneric("moduleHeatmap",
function(x,
useAssay = "counts",
altExpName = "featureSubset",
modules = NULL,
modules = NULL,
featureModule = NULL,
col = circlize::colorRamp2(c(-2, 0, 2),
c("#1E90FF", "#FFFFFF", "#CD2626")),
Expand All @@ -137,8 +134,8 @@ setGeneric("moduleHeatmap",
showModuleLabel = TRUE,
moduleLabel = "auto",
moduleLabelSize = NULL,
width = "auto",
height = "auto",
byrow = TRUE,
top = NA,
unit = "mm",
ncol = NULL,
useRaster = TRUE,
Expand All @@ -150,8 +147,7 @@ setGeneric("moduleHeatmap",
#' @rdname moduleHeatmap
#' @examples
#' data(sceCeldaCG)
#' moduleHeatmap(sceCeldaCG, width = 250, height = 250,
#' displayName = "rownames")
#' moduleHeatmap(sceCeldaCG, displayName = "rownames")
#' @export
setMethod("moduleHeatmap",
signature(x = "SingleCellExperiment"),
Expand Down Expand Up @@ -179,20 +175,20 @@ setMethod("moduleHeatmap",
showModuleLabel = TRUE,
moduleLabel = "auto",
moduleLabelSize = NULL,
width = "auto",
height = "auto",
byrow = TRUE,
top = NA,
unit = "mm",
ncol = NULL,
useRaster = TRUE,
returnAsList = FALSE,
...) {

# 'modules' is an easier parameter name to remember so we include
# support for both.
# 'modules' is an easier parameter name to remember so we include
# support for both.
if(!is.null(modules)) {
featureModule <- modules
}

altExp <- SingleCellExperiment::altExp(x, altExpName)

counts <- SummarizedExperiment::assay(altExp, i = useAssay)
Expand Down Expand Up @@ -285,12 +281,12 @@ setMethod("moduleHeatmap",
# If there is more than 1 module selected, then the miniumum size
# size will be caculated for each module. This will ensure that
# all modules will have the same rowFontSize and the module
# heatmaps will have the same width.
# heatmaps will have the same width.
maxlen <- max(unlist(lapply(featureIndices, length)))
maxlen <- maxlen * sqrt(length(featureIndices))
rowFontSize <- rep(min(200 / maxlen, 20), length(featureIndices))
} else {
# If there is only one plot or each plot will be generated
# If there is only one plot or each plot will be generated
# separately and returned in a list, then the size of the labels,
# will be caculated for each module separately.
len <- unlist(lapply(featureIndices, length))
Expand Down Expand Up @@ -330,7 +326,7 @@ setMethod("moduleHeatmap",
return(plts[[1]])
} else {
if (is.null(ncol)) {
ncol <- floor(sqrt(length(plts)))
ncol <- floor(sqrt(length(plts)))
}
nrow <- ceiling(length(plts) / ncol)

Expand All @@ -340,22 +336,19 @@ setMethod("moduleHeatmap",
wrap.grobs = TRUE)
}

if(isTRUE(returnAsList)) {
figure <- plts
if (isTRUE(returnAsList)) {
figure <- plts
} else {
figure <- multipanelfigure::multi_panel_figure(
columns = ncol,
rows = nrow,
width = width,
height = height,
unit = unit)

for (i in seq(length(plts))) {
figure <- suppressMessages(multipanelfigure::fill_panel(figure,
plts[[i]], label = ""))
}
figure <- gridExtra::marrangeGrob(plts,
ncol = ncol,
nrow = nrow,
layout_matrix = matrix(seq_len(nrow * ncol),
nrow = nrow,
ncol = ncol,
byrow = TRUE),
top = NA)
}

suppressWarnings(return(figure))
}
}
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@ If you are running R 4.0.0 or later version on MacOS Catalina and you see error

https://discourse.mc-stan.org/t/dealing-with-catalina-iii/12731/5

If you are trying to install on MacOS in an Apple Silicon computater and you see the following error:

```
ld: warning: directory not found for option '-L/opt/gfortran/lib/gcc/x86_64-apple-darwin20.0/12.2.0'
ld: warning: directory not found for option '-L/opt/gfortran/lib'
ld: library not found for -lgfortran
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [celda.so] Error 1
ERROR: compilation failed for package ‘celda’
```

You can solve this by downloading and installing the gfortran pkg located [here](https://mac.r-project.org/tools/gfortran-12.2-universal.pkg) and then running the following command:

```
sudo /opt/gfortran/bin/gfortran-update-sdk
```


**NOTE** If you are trying to install **celda** using Rstudio and get this error: `could not find tools necessary to compile a package`, you can try this:
```
options(buildtools.check = function(action) TRUE)
Expand Down
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/CONDUCT.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/LICENSE-text.html

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

Loading

0 comments on commit df08939

Please sign in to comment.