Skip to contents

Plot the cell-type fractions in your simulated dataset

Usage

plot_simulation(simulation)

Arguments

simulation

a simulation object generated by simulate_bulk

Value

a gpplot2 barplot

Examples

counts <- Matrix::Matrix(matrix(stats::rpois(3e5, 5), ncol=300), sparse = TRUE)
tpm <- Matrix::Matrix(matrix(stats::rpois(3e5, 5), ncol=300), sparse = TRUE)
tpm <- Matrix::t(1e6*Matrix::t(tpm)/Matrix::colSums(tpm))

colnames(counts) <- paste0("cell_",rep(1:300))
colnames(tpm) <- paste0("cell_",rep(1:300))
rownames(counts) <- paste0("gene_",rep(1:1000))
rownames(tpm) <- paste0("gene_",rep(1:1000))

annotation <- data.frame("ID"=paste0("cell_",rep(1:300)),
                         "cell_type"=c(rep("T cells CD4",50),
                                       rep("T cells CD8",50),
                                       rep("Macrophages",100),
                                       rep("NK cells",10),
                                       rep("B cells",70),
                                       rep("Monocytes",20)))

dataset <- SimBu::dataset(annotation = annotation,
                          count_matrix = counts,
                          tpm_matrix = tpm,
                          name = "test_dataset")
#> Filtering genes...
#> Created dataset.

s <- SimBu::simulate_bulk(dataset,
                          scenario="even",
                          scaling_factor="NONE",
                          nsamples=10,
                          ncells=100)
#> Finished simulation.

SimBu::plot_simulation(s)
#> Error in rgb(c(166, 31, 178, 51, 251, 227, 253, 255, 202), c(206, 120,     223, 160, 154, 26, 191, 127, 178), c(227, 180, 138, 44, 153,     28, 111, 0, 214), maxColorValue = 255): could not find function "rgb"