malhamdoosh / EGSEA

This package implements the Ensemble of Gene Set Enrichment Analyses (EGSEA) method for gene set testing.
10 stars 4 forks source link

Error in dimnames(x) <- dn : length of 'dimnames' [2] not equal to array extent #21

Closed Chrisdoan9 closed 6 months ago

Chrisdoan9 commented 6 months ago

Hi team,

I would like to find which pathways are different between 2 groups. I got advice to use egsea which combine some methods. However, I got this error:

gsa = egsea.ma(numeric_matrix, vector_group, probe_annotation, contrasts = contrast_matrix, gs.annots = gs.annots, baseGSEAs = baseMethods, sort.by = "avg.rank", num.threads = 4, report = FALSE)
Error in dimnames(x) <- dn : length of 'dimnames' [2] not equal to array extent

expr
double, an K x M numeric matrix of intensities where genes are the rows and samples are the columns. In this case, it is assumed that the expression values are already normalized log2 intensities and filtered, i.e. rows corresponding to control and low-quality probes removed. Row names of expr must match the first column in probe.annot. This is REQUIRED.

probe.annot double, an K x n numeric matrix where rows are probes, the first column contains probe IDs, the second column contains Entrez Gene IDs, and the third column (optional) contains the Gene Symbols. Symbols are used for the heatmap visualization Additional annotation columns can be added for the probes, e.g., Chromosome, QualityScore, etc. These additional columns are not used. This is REQUIRED.

Because the first column of probe.annot contains probe IDs so the first column of expr also probe IDs. So rownames(numeric_matrix) is probe IDs but not entrezID so this code will have error if we won't convert row name numeric_matrix into entrezID: gs.annots <- buildIdx(entrezIDs = rownames(numeric_matrix), species = "human", msigdb.gsets = "c2")

Would you please have a look? Thank you so much!

malhamdoosh commented 6 months ago

Hi @Chrisdoan9

Have you tried to run egsea.ma with verbose = FALSE? this could shed some light on why the error ..please follow the example in the docs on how to prepare your input variables ...

Chrisdoan9 commented 6 months ago

Thanks @malhamdoosh! Will try!

Chrisdoan9 commented 6 months ago

Hi @malhamdoosh,

filtered_matrix type is a large matrix, columns are samples name, rows are probeSetID, values are microarray normalized and log transformed. vector_groups are factor with information the type of a sample is control or disease. probe_annotation is a list with 2 columns: first column is probeSetID (as the documentation require) and second column is EntrezID contrast_matrix is double, one column for comparison

gs.annots <- buildIdx(entrezIDs = rownames(numeric_matrix), species = "human", msigdb.gsets = "c2")
baseMethods <- c("camera", "gsva")

To able to runbuildIdx(), the row name of numeric_matrix is entrezIDs. Then I reformat row name of numeric_matrix into probeSetID to satisfy the requirement of expr and probe.annot in the document. I tried verbose = FALSE and got the same error message. Also tried egsea() with different inputs but got other errors. Thank you so much!

Chrisdoan9 commented 4 months ago

I fixed the error. Thank you!