Entering edit mode
4.5 years ago
tpm
▴
30
My question is related to the tutorial from this link (https://yulab-smu.github.io/clusterProfiler-book/chapter11.html#formula-interface-of-comparecluster). From this code below, what needs to be modified in order to add more groups if I have “A”, “B”, “C”, “D”....when I don’t only have "A" and "B" states as like seen in this case.
mydf <- data.frame(Entrez=names(geneList), FC=geneList)
mydf <- mydf[abs(mydf$FC) > 1,]
mydf$group <- "upregulated"
mydf$group[mydf$FC < 0] <- "downregulated"
mydf$othergroup <- "A"
mydf$othergroup[abs(mydf$FC) > 2] <- "B"
formula_res <- compareCluster(Entrez~group+othergroup, data=mydf, fun="enrichKEGG")
My raw data sample may be looking like this:
gene FC othergroup
glnD 5.237895088 A
eutC 4.64146896 C
mscM 3.947759653 B
tatA 3.920706166 D
elaB -3.785411053 D
fliI 3.548765407 A
sapD -3.388648775 B
ppnP 3.345254427 C
ybhA -3.190667532 C
ilvE 2.900593133 C
tatE 2.865852846 C
oppC 2.853396894 D
glsA1 -2.672349905 D
rnpA 2.563564924 D
ratB 2.473440589 A
ftsI 2.418999465 A
galP -2.410974203 A
fpr 2.379620962 B
mntR 2.364759177 B
ygiS -2.337045006 C
speC -2.252678046 C
srlA 2.227433038 D
yqcA 2.217127294 D
fldB 2.192615021 A
From this above data seems like you already have othergroup in your data. That above code tried to add group based on conditions.
The above code will generate a dataframe something like this -
mydf
So just create such a dataframe then Its matter of using those group header (group, othergroup) names in the formula.