Create “rnk” file for GSEA

Ambu Vijayan
1 min readFeb 9, 2023

--

GSEA stands for Gene set enrichment analysis.

I was tring to learn gsea and i stumbled upon a step where i had to provide an rnk file. Had to do a lot of digging and finally i found it.

Thought i might share this here in case someone is looking to achieve the same goal.

Asusual i am using R for achieving this.

We need the DGE file from edgeR. Here the file name is “expression_edgeR.xls”.

#Uploads the excel file into R
x<-read.table("expression_edgeR.xls",sep="\t",header=T)

#Attaches the excel file
attach(x)

#Generates a new column that is the sign of fold change.
x$fcSign=sign(logFC)

#Generates a new column that is the negative log10 of the p-value.
x$logP=-log10(PValue)

#Generates a new column that is the metric score that we'll use for ranking and pathway analysis
x$metric=logP/fcSign

#Makes a new table called "y" that consists only of gene names and metric scores.
y<-x[,c("Name", "metric")]

#Write.table command outputs the gene name and rank metric data to a new file called "expression.rnk".
write.table(y,file="expression.rnk",quote=F,sep="\t",row.names=F)

--

--

Ambu Vijayan

Bioinformatics Analyst, Statistical Consultant, R-Programmer