ahmohamed / lipidr

Data Mining and Analysis of Lipidomics datasets in R
https://www.lipidr.org/
Other
27 stars 13 forks source link

de_analysis, group_col names #39

Closed DavidGO464 closed 1 year ago

DavidGO464 commented 1 year ago

Hi!,

having this in the documentation: "de_analysis(data, ..., measure = "Area", group_col = NULL)"

I created a lipidomics experiment and then added the annotation ("d1"). The data set of the annotation has two columns (the first is "Sample" and the second is "fibrosis_score_adj", this score are numerical ranges like 0-2 vs 3-4) when I set the name of the column in the "group_col" argument:

de_analysis(d1, 0-2 - 3-4, measure = "Area", group_col = fibrosis_score_adj)

the output is:

Error in de_analysis(d, 0 - 2 - 3 - 4, measure = "Area", group_col = "fibrosis_score_adj") : No contrasts provided

How can I make de_analysis work properly?

and also, what do you recommend to put first in the "..." argument of de_analysis: the control or the experimental?

kind regards

by the way: Yes, the categories inside "fibrosis_score_adj" are "0-2" and "3-4"

ahmohamed commented 1 year ago

Your annotation column is treated numeric continuous variable. If we want it categorical, you can convert it to character. To be safe, just add any prefix to your scores. Something like d1$fibrosis_score_adj = paste0("FS", d1$fibrosis_score_adj) would work. And your de_analysis would become de_analysis(d1, (FS0-FS2) - (FS3-FS4), measure = "Area", group_col = fibrosis_score_adj)

ahmohamed commented 1 year ago

Sorry just noticed your last line. Ignore the comment above.

The safe way is to syntactically valid variable names in R. For example R0_2 (no spaces, minus, doesn't start with a number). Alternatively you can try to enclose your variables with back ticks like that:

de_analysis(d1, `0-2` - `3-4`, measure = "Area", group_col = "fibrosis_score_adj")

Note also the group_col needs double qoutes.

DavidGO464 commented 1 year ago

Thank you so much!!!