This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to extract fold change data for a list of specified genes using R?

I am a newbie to R and I am analyzing expression data from an Illumina array. I have imported the excel file to R which includes in my column titles GENE SYMBOL and FOLD CHANGE. In this file there is fold change data for almost every gene in the genome. I want to know how to extract the fold change values for a list of specified gene names which will be under the gene symbol column.

genome r expression-array gene

vlookup in excel does the same trick.

1 answer

# Make or load a list of genes that you want to check:
query.genes <- c("gene1", "gene2")

# Subset the data frame for these genes
tmp.subset <- your.df[your.df$genes == query.genes,]

# and get the column with the FCs
tmp.subset$FC

Adjust the names after $ according to your column names.

EDIT: Also, if your column name is really GENE SYMBOL, try to get used to avoid whitespaces and rather use GENE_SYMBOL or similar delimiters (and of course never use Excel :-D )

Hi. Thanks so much. I am completely new to R. My colum title is actually just SYMBOL. When I try the second part: tmp.subset <- your.df[your.df$genes == query.genes,] It tells me : longer object length is not a multiple of shorter object length. What does this mean? Also I assume I replace "your.df" with the name of my file.

Log in to answer this question.