My collegue Samantha asked a unclear question, so here I ask here question.
She has a variable goterms, containing all dataframes to be analyzed.
goterms <- c('df1','df2','df3')
The interestedGO variable contains for each goterm a lists with ILMN numbers. So the first list contains the ILMN codes of df1 ans so on.
df1 <- c("ILMN_1665132", "ILMN_1691487", "ILMN_1716446", "ILMN_1769383",
"ILMN_1772387", "ILMN_1783910", "ILMN_1784863")
df2 <- c("ILMN_1651599", "ILMN_1652693", "ILMN_1652825", "ILMN_1653324",
"ILMN_1655595", "ILMN_1656057", "ILMN_1659077", "ILMN_1659923",
"ILMN_1659947", "ILMN_1662322", "ILMN_1662619", "ILMN_1664565",
"ILMN_1665132", "ILMN_1665738", "ILMN_1665859")
df3 <- c("ILMN_1661695", "ILMN_1665132", "ILMN_1716446", "ILMN_1737314",
"ILMN_1772387", "ILMN_1784863", "ILMN_1796094", "ILMN_1800317",
"ILMN_1800512", "ILMN_1807074")
interestedGO <- list(df1,df2,df3)
The xx2 is a comparison set. The xx2 variable contains a subset of all possible ILMN numbers.
xx2 <- c("ILMN_1691487", "ILMN_1716446", "ILMN_1769383","ILMN_1832921")
The x is a sort of reference set. The x variable contains all possible ILMN numbers.
x <- c("ILMN_1665132", "ILMN_1691487", "ILMN_1716446", "ILMN_1769383", "ILMN_1772387",
"ILMN_1783910", "ILMN_1784863","ILMN_1651599", "ILMN_1652693", "ILMN_1652825",
"ILMN_1653324", "ILMN_1655595","ILMN_1656057", "ILMN_1659077", "ILMN_1659923",
"ILMN_1659947", "ILMN_1662322","ILMN_1662619", "ILMN_1664565", "ILMN_1665132",
"ILMN_1665738", "ILMN_1665859","ILMN_1661695", "ILMN_1665132", "ILMN_1716446",
"ILMN_1737314", "ILMN_1772387","ILMN_1784863", "ILMN_1796094", "ILMN_1800317",
"ILMN_1800512", "ILMN_1807074")
With all these variables the goal is to check for each goterm with corresponding ILMN codes if they are in the referenceset xx2. To check for this, the match function is used, and all no matches gives a 0 and the matched values are replaced by 1. To give an handy overview of all the goterms experiments, I want to create a loop like below, that checks for each gene of it is in the reference set x. The final result must be a data.frame that compare the results of each goterm in a data.frame.
test <- list()
for (i in 1:length(goterms)) {
goilmn <- as.data.frame(interestedGO[i])
resultILMN <- match(goilmn[,1], xx2, nomatch=0)
resultILMN[resultILMN!=0] <- 1
result <- cbind(goilmn, resultILMN)
colnames(result) <- c('x', 'result')
zz <- merge(result, x, all=TRUE)
zz[is.na(zz)] <- 0
test[[i]] <- matrix(resultloop)
}
The final output will be just like this:
1 ILMN_1651599 0 0 0
2 ILMN_1652693 0 0 0
3 ILMN_1652825 0 0 0
4 ILMN_1653324 0 0 0
5 ILMN_1655595 0 0 0
6 ILMN_1656057 0 0 0
7 ILMN_1659077 0 0 0
8 ILMN_1659923 0 0 0
9 ILMN_1659947 0 0 0
10 ILMN_1661695 0 0 0
11 ILMN_1662322 0 0 0
12 ILMN_1662619 0 0 0
13 ILMN_1664565 0 0 0
14 ILMN_1665132 0 0 0
15 ILMN_1665132 0 0 0
16 ILMN_1665132 0 0 0
17 ILMN_1665738 0 0 0
18 ILMN_1665859 0 0 0
19 ILMN_1691487 0 0 1
20 ILMN_1716446 1 0 1
21 ILMN_1716446 1 0 1
22 ILMN_1737314 0 0 0
23 ILMN_1769383 0 0 1
24 ILMN_1772387 0 0 0
25 ILMN_1772387 0 0 0
26 ILMN_1783910 0 0 0
27 ILMN_1784863 0 0 0
28 ILMN_1784863 0 0 0
29 ILMN_1796094 0 0 0
30 ILMN_1800317 0 0 0
31 ILMN_1800512 0 0 0
32 ILMN_1807074 0 0 0
Can anyone help me with this?
Thanks!
Does this work for you?