How to get the gene names corresponding to genes in a module in R?
1
0
Entering edit mode
3.8 years ago

On doing module extraction from a rna-seq dataset, I get the module as a text file containing the index number of the gene and not the gene names. I have saved the gene names from the original gene expression file in a variable "geneNames". How do I match the index number from the module file with the index number of geneNames to get the corresponding gene name for the genes in the module? The coding language used is R.

gene rna-seq R • 1.4k views
ADD COMMENT
1
Entering edit mode
3.8 years ago
geneNames
[1] "Gene1" "Gene2" "Gene3" "Gene4"

Import your text file back into R. If there are column names in your text file, set col_names = TRUE

module <- read.tsv(file = "textfie.txt", col_names = FALSE)
module
1 2
2 3
3 1

In R, you can extract values from a vector using the position. So in this case, the positions are in the first column of the data frame.

geneNames[module[[1]]]
"Gene2" "Gene3" "Gene1"
ADD COMMENT

Login before adding your answer.

Traffic: 1269 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