Skip to content

Commit

Permalink
Merge pull request #48 from omnideconv/devel
Browse files Browse the repository at this point in the history
Devel branch
  • Loading branch information
alex-d13 authored Nov 8, 2023
2 parents 5646b3a + ba47326 commit dcf899e
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: SimBu
Title: Simulate Bulk RNA-seq Datasets from Single-Cell Datasets
Version: 1.1.5
Version: 1.5.0
Authors@R:
person(given = "Alexander",
family = "Dietrich",
Expand Down
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
10 changes: 5 additions & 5 deletions 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 Expand Up @@ -483,8 +483,8 @@ dataset_seurat <- function(seurat_obj, counts_layer, cell_id_col, cell_type_col,
if (is.null(counts_layer)) {
stop("You have to provide the name of the layer in the Seurat object that contains count data.")
}
if(!is.null(assay)){
message(paste('Changing default assay to', assay))
if (!is.null(assay)) {
message(paste("Changing default assay to", assay))
Seurat::DefaultAssay(seurat_obj) <- assay
}
active_assay <- Seurat::DefaultAssay(seurat_obj)
Expand Down Expand Up @@ -516,7 +516,7 @@ dataset_seurat <- function(seurat_obj, counts_layer, cell_id_col, cell_type_col,

tryCatch(
{
count_matrix <- SeuratObject::LayerData(seurat_obj, layer = 'counts')
count_matrix <- SeuratObject::LayerData(seurat_obj, layer = "counts")
},
error = function(e) {
em <- paste("Could not access count matrix from Seurat object (counts): ", e)
Expand All @@ -529,7 +529,7 @@ dataset_seurat <- function(seurat_obj, counts_layer, cell_id_col, cell_type_col,
if (!is.null(tpm_assay)) {
tryCatch(
{
tpm_matrix <- SeuratObject::LayerData(seurat_obj, layer = 'data')
tpm_matrix <- SeuratObject::LayerData(seurat_obj, layer = "data")
},
error = function(e) {
em <- paste("Could not access count matrix from Seurat object (tpm): ", e)
Expand Down
2 changes: 1 addition & 1 deletion 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
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 man/dataset_h5ad.Rd

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

4 changes: 2 additions & 2 deletions man/sfaira_overview.Rd

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

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 dcf899e

Please sign in to comment.