Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 7, 2023
1 parent 3944072 commit c01e13f
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions R/access_sfaira.R
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,12 @@ download_sfaira_multiple <- function(setup_list, organisms = NULL, tissues = NUL
#' @return a dataframe with information on each dataset
#' @export
#'
#' @examples
#' @examples
#' \donttest{
#' setup_list <- setup_sfaira(basedir=tempdir())
#' # all_datasets <- sfaira_overview(setup_list)
#' setup_list <- setup_sfaira(basedir = tempdir())
#' # all_datasets <- sfaira_overview(setup_list)
#' }
sfaira_overview <- function(setup_list){
sfaira_overview <- function(setup_list) {
# create conda environment with sfaira
proc <- basilisk::basiliskStart(SimBu_env)
on.exit(basilisk::basiliskStop(proc))
Expand Down
1 change: 0 additions & 1 deletion R/basilisk.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

# dependencies for sfaira and anndata0.7.6 (taken from zellkonverter package)
SimBu_env <- basilisk::BasiliskEnvironment(
envname = "SimBu_env_1_1_1",
Expand Down
1 change: 0 additions & 1 deletion R/census.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#' Applies the Census count transformation on a count matrix
#'
#' needs a sparse matrix with cells in columns and genes in rows. You can find the detailed explaination here:
Expand Down
2 changes: 1 addition & 1 deletion R/dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ dataset_merge <- function(dataset_list, name = "SimBu_dataset", spike_in_col = N
#' @export
#'
#' @examples
#' #h5 <- system.file("extdata", "anndata.h5ad", package = "SimBu")
#' # h5 <- system.file("extdata", "anndata.h5ad", package = "SimBu")
#' # ds_h5ad <- SimBu::dataset_h5ad(
#' # h5ad_file_counts = h5,
#' # name = "h5ad_dataset",
Expand Down
28 changes: 15 additions & 13 deletions R/simulator.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ simulate_sample <- function(data,
} else {
# how many cells of this type do we need?
n <- round(total_cells * simulation_vector[x])
if(n == 0){
if (n == 0) {
n <- 1
}
cells <- dplyr::slice_sample(cells_of_type_x, n = n, replace = TRUE)
Expand Down Expand Up @@ -443,22 +443,24 @@ simulate_bulk <- function(data,
return(samples)
}, BPPARAM = BPPARAM)

bulk_counts <- Matrix::Matrix(vapply(
X = all_samples,
FUN = "[[",
... = 1,
FUN.VALUE = double(dim(SummarizedExperiment::assays(data)[["counts"]])[1])
),
sparse = TRUE
)
if ("tpm" %in% names(SummarizedExperiment::assays(data))) {
bulk_tpm <- Matrix::Matrix(vapply(
bulk_counts <- Matrix::Matrix(
vapply(
X = all_samples,
FUN = "[[",
... = 2,
FUN.VALUE = double(dim(SummarizedExperiment::assays(data)[["tpm"]])[1])
... = 1,
FUN.VALUE = double(dim(SummarizedExperiment::assays(data)[["counts"]])[1])
),
sparse = TRUE
)
if ("tpm" %in% names(SummarizedExperiment::assays(data))) {
bulk_tpm <- Matrix::Matrix(
vapply(
X = all_samples,
FUN = "[[",
... = 2,
FUN.VALUE = double(dim(SummarizedExperiment::assays(data)[["tpm"]])[1])
),
sparse = TRUE
)
assays <- list(bulk_counts = bulk_counts, bulk_tpm = bulk_tpm)
} else {
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

<!-- README.md is generated from README.Rmd. Please edit that file -->

# SimBu
Expand All @@ -10,6 +9,7 @@
[![docs](https://img.shields.io/badge/docs-pkgdown-blue.svg)](https://omnideconv.github.io/SimBu)
[![Codecov test
coverage](https://codecov.io/gh/omnideconv/SimBu/branch/master/graph/badge.svg)](https://app.codecov.io/gh/omnideconv/SimBu?branch=master)

<!-- badges: end -->

The goal of SimBu is to simulate pseudo-bulk RNAseq datasets with
Expand All @@ -20,14 +20,14 @@ RNAseq datasets.

To install the developmental version of the package, run:

``` r
```r
install.packages("devtools")
devtools::install_github("omnideconv/SimBu")
```

To install from Bioconductor:

``` r
```r
if (!require("BiocManager", quietly = TRUE)) {
install.packages("BiocManager")
}
Expand All @@ -40,7 +40,7 @@ BiocManager::install("SimBu")
Create a dataset-object with local data and simulate a pseudo-bulk
dataset

``` r
```r
library(SimBu)
# use local data to build dataset
dataset <- dataset(annotation = annotation_dataframe, count_matrix = expression_matrix, name = "test_dataset")
Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test_dataset.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ test_that("can create dataset from seurat object", {
# test_that("can load h5ad file with cells in obs and var", {
# h5 <- system.file("extdata", "anndata.h5ad", package = "SimBu")
# h5_rev <- system.file("extdata", "anndata_rev.h5ad", package = "SimBu")
#
#
# testthat::expect_s4_class(SimBu::dataset_h5ad(h5ad_file_counts = h5, name = "h5ad_dataset", cell_id_col = "id", cell_type_col = "group", cells_in_obs = TRUE), "SummarizedExperiment")
# testthat::expect_s4_class(SimBu::dataset_h5ad(h5ad_file_counts = h5_rev, name = "h5ad_dataset", cell_id_col = "id", cell_type_col = "group", cells_in_obs = FALSE), "SummarizedExperiment")
# })
Expand Down
6 changes: 3 additions & 3 deletions vignettes/simulator_input_output.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ As this function uses the `SimBu` python environment to read the h5ad files and

```{r}
# example h5ad file, where cell type info is stored in `obs` layer
#h5 <- system.file("extdata", "anndata.h5ad", package = "SimBu")
#ds_h5ad <- SimBu::dataset_h5ad(
# h5 <- system.file("extdata", "anndata.h5ad", package = "SimBu")
# ds_h5ad <- SimBu::dataset_h5ad(
# h5ad_file_counts = h5,
# name = "h5ad_dataset",
# cell_id_col = 0, # this will use the rownames of the metadata as cell identifiers
# cell_type_col = "group", # this will use the 'group' column of the metadata as cell type info
# cells_in_obs = TRUE # in case your cell information is stored in the var layer, switch to FALSE
#)
# )
```

## Merging datasets
Expand Down

0 comments on commit c01e13f

Please sign in to comment.