Code to find the list of genes in the DEG table in R?
2
0
Entering edit mode
2.5 years ago
Maryam • 0

Hello to all

I have a list of invasive genes, on the other hand I have a DEG table, now I want to know if my list of genes is in the DEG table or not? How can I do this in R? With what code?

Thanks in advance

R • 1.2k views
ADD COMMENT
0
Entering edit mode

instead of subsetting, just do an enrichment testing.

ADD REPLY
0
Entering edit mode

Thank you.

ADD REPLY
0
Entering edit mode
2.5 years ago
Basti ★ 2.0k

You could use intersect(). Assuming invasive is a vector of invasive genes and df is your DEG table containing a column gene, you would do :

intersect(invasive, df$gene)
ADD COMMENT
0
Entering edit mode

Thank you so much.

ADD REPLY
0
Entering edit mode
2.5 years ago
seidel 11k

You can use the %in% operator in R to ask "is this in that"? The result will be a boolean vector, which you can use to return any positions of your data frame that are TRUE. For example:

# create a data frame with 2 columns of experimental results
DEgenes <- data.frame(exp1_FC=rnorm(20), exp2_FC=rnorm(20))

# assign gene names to the rows
rownames(DEgenes) <- paste0("g", 1:nrow(DEgenes))

# make a vector of invasive genes
invasive <- c("g3", "g7", "g11", "g3145")

# Are any of the DE genes in our invasive vector?
DEgenes[rownames(DEgenes) %in% invasive,]

        exp1_FC    exp2_FC
g3  -0.04853683 -0.8079399
g7  -0.21303331  0.3234412
g11  0.30011850 -0.2239166
ADD COMMENT
0
Entering edit mode

Thanks a lot.

ADD REPLY

Login before adding your answer.

Traffic: 2291 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6