Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Q: possible to simulate group-specific cde? #178

Open
HelenaLC opened this issue Nov 25, 2024 · 1 comment
Open

Q: possible to simulate group-specific cde? #178

HelenaLC opened this issue Nov 25, 2024 · 1 comment
Assignees
Labels

Comments

@HelenaLC
Copy link

HelenaLC commented Nov 25, 2024

Quick Q. We're using splatter to simulate 3 vs. 3 samples from 2 conditions, 3 clusters. However, it seems condition-differences cde are introduced "global"ly, i.e., all the same for every de group. Any way we could alter this? E.g., have cde only affect one group?

I tried simulating clusters independently with fixed seed, which let's me control cde. However, this kills any de between clusters, so it won't do... exemplary PCs and corresponding code below.

Hope that makes sense & happy to clarify if not. Cheers!!

image


seed <- 241122
t <- 1.5; s <- 2; b <- 0

vcf <- mockVCF(n.samples=6, seed=seed)
gff <- mockGFF(n.genes=800, seed=seed)

# simulate 'Group's = clusters in a loop
lys <- lapply(seq(3), \(.) {
    # set 'cde.facLoc=s' = condition effect
    # in all but one 'Group' = cluster
    if (. != 1) s <- 0 
    set.seed(seed)
    # simulate w/o DE effects
    p <- newSplatPopParams(
        # type
        #de.facLoc=t,
        #de.prob=0.1,
        #de.facScale=0.1*t,
        # state
        cde.prob=0.1,
        cde.facLoc=s,
        cde.facScale=0.1,
        bcv.common=1.5,
        batchCells=50,
        eqtl.ES.rate=30,
        similarity.scale=15,
        #group.prob=rep(1/3, 3), # cluster
        condition.prob=c(0.5, 0.5)) # condition
    
    # multiply overall 'lib.loc' by 1+'t' = cluster effect
    # (now clusters are always the same, though...?)
    # (and changing this would affect all genes...?)
    attr(p, ll) <- attr(p, ll <- "lib.loc")*(1+t)
    
    sim <- splatPopSimulate(
        params=p, vcf=vcf, gff=gff,
        verbose=FALSE, sparsify=FALSE)
    sim$Group <- letters[.]
    return(sim)
})

tmp <- lapply(lys, \(.) {
    rowData(.) <- NULL
    .
})
x <- do.call(cbind, tmp)
colData(x) <- DataFrame(
    cluster_id=x$Group,
    sample_id=x$Sample,
    group_id=x$Condition)
@lazappi
Copy link
Collaborator

lazappi commented Nov 26, 2024

Hi @HelenaLC

Thanks for giving {splatter} a go! As this relates to splatPop I'm hoping @azodichr can jump in with an answer. If not I'll try to look into it but it will take me a bit to get my head around how it works again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants