### Install SPsimSeq from GitHub Source: https://github.com/centerforstatistics-ugent/spsimseq/blob/master/README.md Installs the SPsimSeq package directly from its GitHub repository using the devtools package. Ensure devtools is installed first. ```r library(devtools) install_github("CenterForStatistics-UGent/SPsimSeq") ``` -------------------------------- ### Load SPsimSeq and Check Version Source: https://github.com/centerforstatistics-ugent/spsimseq/blob/master/README.md Loads the SPsimSeq package and prints its currently installed version. This is a good practice to ensure the correct version is loaded. ```r suppressPackageStartupMessages(library(SPsimSeq)) cat("SPsimSeq package version", as.character(packageVersion("SPsimSeq")), "\n") ``` -------------------------------- ### Install SPsimSeq from Bioconductor Source: https://github.com/centerforstatistics-ugent/spsimseq/blob/master/README.md Installs the SPsimSeq package from Bioconductor using the BiocManager package. This is the recommended method for stable releases. ```r library(BiocManager) BiocManager::install("SPsimSeq") ``` -------------------------------- ### Simulate Bulk RNA-seq Data Source: https://github.com/centerforstatistics-ugent/spsimseq/blob/master/README.md Simulates bulk RNA-seq count data using the SPsimSeq function. This example configures simulation parameters such as the number of genes, samples, groups, differential expression proportion, and fold-change threshold. ```r # load the Zhang bulk RNA-seq data data("zhang.data.sub") # filter genes with sufficient expression (important step) zhang.counts <- zhang.data.sub$counts[rowSums(zhang.data.sub$counts > 0)>=5, ] # We simulate only a single data (n.sim = 1) with the following property # - 2000 genes ( n.genes = 2000) # - 20 samples (tot.samples = 20) # - the samples are equally divided into 2 groups each with 90 samples # (group.config = c(0.5, 0.5)) # - all samples are from a single batch (batch = NULL, batch.config = 1) # - we add 10% DE genes (pDE = 0.1) # - the DE genes have a log-fold-change of at least 0.5 in # the source data (lfc.thrld = 0.5) # - we do not model the zeroes separately, they are the part of density # estimation (model.zero.prob = FALSE) # simulate data set.seed(6452) zhang.counts2 <- zhang.counts[sample(nrow(zhang.counts), 2000), ] sim.data.bulk <- SPsimSeq(n.sim = 1, s.data = zhang.counts2, group = zhang.data.sub$MYCN.status, n.genes = 2000, batch.config = 1, group.config = c(0.5, 0.5), tot.samples = 20, pDE = 0.1, lfc.thrld = 0.5, result.format = "list") ``` -------------------------------- ### Inspect Simulated Bulk RNA-seq Sample Information Source: https://github.com/centerforstatistics-ugent/spsimseq/blob/master/README.md Displays the first few rows of the sample metadata generated during the bulk RNA-seq simulation. This includes batch, group, and library size information for each sample. ```r head(sim.data.bulk1$colData) # sample info ``` -------------------------------- ### Simulate Single-Cell RNA-Seq Data Source: https://github.com/centerforstatistics-ugent/spsimseq/blob/master/README.md Simulates a single-cell RNA-Seq dataset with specified parameters. This includes setting the number of genes, cells, group configurations, batch information, proportion of differentially expressed genes, log-fold-change threshold, zero probability modeling, and output format. Requires the SingleCellExperiment package. ```r suppressPackageStartupMessages(library(SingleCellExperiment)) data("scNGP.data") scNGP.data2 <- scNGP.data[rowSums(counts(scNGP.data) > 0)>=5, ] treatment <- ifelse(scNGP.data2$characteristics..treatment=="nutlin",2,1) set.seed(654321) scNGP.data2 <- scNGP.data2[sample(nrow(scNGP.data2), 2000), ] sim.data.sc <- SPsimSeq(n.sim = 1, s.data = scNGP.data2, group = treatment, n.genes = 2000, batch.config = 1, group.config = c(0.5, 0.5), tot.samples = 100, pDE = 0.1, lfc.thrld = 0.5, model.zero.prob = TRUE, result.format = "SCE") ``` -------------------------------- ### Inspect Simulated Bulk RNA-seq Counts Source: https://github.com/centerforstatistics-ugent/spsimseq/blob/master/README.md Displays the first few rows and columns of the simulated gene count data from the bulk RNA-seq simulation. This helps in verifying the structure and initial values of the simulated counts. ```r sim.data.bulk1 <- sim.data.bulk[[1]] head(sim.data.bulk1$counts[, seq_len(5)]) # count data ``` -------------------------------- ### Inspect Simulated Gene Counts Source: https://github.com/centerforstatistics-ugent/spsimseq/blob/master/README.md Displays the first few rows and columns of the raw counts matrix within the simulated SingleCellExperiment object. This provides a glimpse of the gene expression values for the initial cells. ```r head(counts(sim.data.sc1)[, seq_len(5)]) ``` -------------------------------- ### Access Simulated Data from SingleCellExperiment Object Source: https://github.com/centerforstatistics-ugent/spsimseq/blob/master/README.md Extracts the simulated data as a SingleCellExperiment object from the list returned by SPsimSeq. This allows for inspection of the simulated counts, cell metadata, and gene annotations. ```r sim.data.sc1 <- sim.data.sc[[1]] class(sim.data.sc1) ``` -------------------------------- ### Inspect Cell Metadata Source: https://github.com/centerforstatistics-ugent/spsimseq/blob/master/README.md Retrieves and displays the column data (metadata) for the cells in the simulated SingleCellExperiment object. This includes information on batch, group assignment, and simulated library size. ```r colData(sim.data.sc1) ``` -------------------------------- ### Inspect Simulated Bulk RNA-seq Gene Information Source: https://github.com/centerforstatistics-ugent/spsimseq/blob/master/README.md Displays the first few rows of the gene metadata generated during the bulk RNA-seq simulation. This includes whether a gene was designated as differentially expressed (DE.ind) and its source ID. ```r head(sim.data.bulk1$rowData) # gene info ``` -------------------------------- ### Inspect Gene Annotations Source: https://github.com/centerforstatistics-ugent/spsimseq/blob/master/README.md Retrieves and displays the row data (annotations) for the genes in the simulated SingleCellExperiment object. This indicates whether a gene was marked as differentially expressed (DE.ind) and its source ID. ```r rowData(sim.data.sc1) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.