This function generates a pseudo bulk samples by random sampled number of cells per subject.

generateBulk(eset,ct.varname,sample,disease = NULL,ct.sub,prop_mat = NULL,
nbulk = 50,samplewithRep = FALSE,low_s = 0.3,upp_s = 0.7)

Arguments

eset

The `ExpressionSet` object for single cells.

ct.varname

Variable name for 'cell types'.

sample

Variable name for subject/samples.

disease

Indicate the health condition of subjects.

ct.sub

A subset of cell types that are selected to construct pseudo bulk samples. If NULL, then all cell types are used.

prop_mat

Manually input the cell-type proportion for pseudo bulk samples.

nbulk

The number of pseudo bulk samples to be constructed.

samplewithRep

Logical, randomly sample single cells with replacement. Default is F.

low_s

Lower support a for uniform distribution U[a,b].

upp_s

Upper support b for uniform distribution U[a,b].

Value

Pseudo bulk samples in the format of `ExpressionSet`, and the true cell-type proportions.

Examples

##read data
library(InteRD)
readRDSFromWeb<-function(ref) {readRDS(gzcon(url(ref)))}
urlremote<-"https://github.com/chencxxy28/Data/raw/main/data_InteRD/"
seger<-readRDSFromWeb(paste0(urlremote,"segerstolpe.rds"))

##generate a pseudo bulk data with two samples
set.seed(1234567)
pseudo.seger<-generateBulk(seger[["sc.eset.qc"]], ct.varname = "cluster",
sample = "sample", ct.sub = c("alpha","beta","delta","gamma"),
nbulk = 2, low_s = 0.3, upp_s = 0.7)
#> Using 4 cell types to generate pseudo bulk samples...
#> Generating random cell type proportions...
#> generating bulk 1 from donor one...
#> generating bulk 2 from donor one...
#> generating expression set object for pseudo bulk sample.id...