lmweber / diffcyt

R package for differential discovery analyses in high-dimensional cytometry data
MIT License
19 stars 12 forks source link

diffcyt-DA-edgeR Design and Contrast #38

Closed crchinfatt closed 2 years ago

crchinfatt commented 2 years ago

Hi, I am running any analysis with 59 samples. I have one outcome variable so for my design, I created it as follows:

design <- createDesignMatrix(experiment_info,cols_design = c("Outcome"))

This outcome is set as a factor of 0s and 1s.

For the contrast,

contrast <- createContrast(c(0, 1, rep(0, 58)))

However when I run the check I get an error that the number of columns in the design and rows in the contrast aren't the same. Since my design only contrasts contrast, it will be two columns (intercept and outcome).

This is the final command, I am running (59 samples 64 markers where 32 of these are the ones I am interested in),

out_DA <- diffcyt( d_input = d_flowSet, experiment_info = experiment_info, marker_info = marker_info, design = design, contrast = contrast, analysis_type = "DA", seed_clustering = 123 )

This is the error from diffcyt:

preparing data... transforming data... generating clusters... FlowSOM clustering completed in 258.2 seconds calculating features... calculating DA tests using method 'diffcyt-DA-edgeR'... Error in glmLRT(fit, contrast = contrast) : contrast vector of wrong length, should be equal to number of coefficients in the linear model.

Can you please guide me on where I am going wrong?

Many thanks, Cherise.

crchinfatt commented 2 years ago

For anyone who might run into this problem, I have figured out the problem. If you are interested in one outcome the contrast will need to be updated as follows:

contrast <- createContrast(c(0, 1))

where 1 represents the outcome.