analyze and compare PValues in 2 csv file by python
0
0
Entering edit mode
5.5 years ago

Hi all,

I am doing an RNA-seq analysis. I have two CSV files, and I want to get a set of data of my genes during P Values to know which genes in each CSV file are up regulated. EdgeR achieves the tables in differential gene expression in R studio, and the script is written down. I use the codes for both tables that I have for gene counts achieved by ht-seq. At frist i want to know which genes are common among two tables and then use a python script to build a set or table to tell me which genes in each table are up regulated and which are not from the mutual ones that i find. The P value that i consider is < 5% . How can I do it by python? Also there is a point that i have to mention that the genes orders(first column) in the tables are not the same and they are different!

library(edgeR)

group <- factor(c(rep("pro-vaccine",30),rep("pre_vaccine",20)))
x<-read.csv("table_50_ID.csv")
y<-DGEList(counts = x, group=group)
y<-calcNormFactors(y)
design<-model.matrix(~group)
y<-estimateDisp(y,design)
fit<-glmFit(y,design)
lrt<-glmLRT(fit,coef = 2)
deg <-topTags(lrt, n = Inf , p= 0.05)$table
up <-deg[deg$logFC > 0,]
down <-deg[deg$logFC < 0,]
write.csv(up, file="up.csv")
write.csv(down, file="down.csv")

Here is also my tables shapes in R studio:

table

Thanks in advance

python csv RNA-Seq • 2.3k views
ADD COMMENT
0
Entering edit mode

Why do you need to use python? If you're reading files into R, why not use R to compare columns of a data.frame to achieve what you need?

ADD REPLY
0
Entering edit mode

the problem is i am not a R programmer and i am not into that! i just use this package because i am stimulating an article process! that is also why i want to compare two tables which is mine and them!

ADD REPLY
0
Entering edit mode

In that case, I'd recommend you read up on pandas and use that to compare/manipulate your datasets.

https://pandas.pydata.org/

Also, in this case, the R code you supplied has nothing to do with the exercise, as you merely need to understand how to work with tabular data/CSV files in python.

ADD REPLY
0
Entering edit mode

i saw the suggestions are toward pandas but i couldn't adopt what i want in the exercise by pandas but as it seems the only solution is to do it! the code is just to show what i use to create for my tables! that is it!

ADD REPLY
0
Entering edit mode

Yes, you're going to have to learn one technology or the other.

A side note: Use the ! mark judiciously. It can make sentences appear quite prickly when used improperly or overused.

ADD REPLY
0
Entering edit mode

thanks anyway. i didn't mean anything by "!". pardon me if you i irritate you by that.

ADD REPLY
0
Entering edit mode

No problem, it's just quirks with language usage.

ADD REPLY

Login before adding your answer.

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