Gene expression file to Expression matrix
1
0
Entering edit mode
3.5 years ago
David_emir ▴ 490

Hi All,

I have an RNAseq gene expression file (Count data) as follows, I need to conduct a Differential gene expression analysis between Patients, for that, I need to have this file as a Matrix of Rows as Genes and columns as counts (samples), how best can I get this as matrix file?

Thanks a lot for your help, Stay safe

Dave

like this

RNA-Seq • 1.6k views
ADD COMMENT
0
Entering edit mode

You'll need to use something like tidyr::pivot_wider() to get patient_id to columns and retain gene_code as rows. You'll end up picking one of gene_raw/gene_tpm as the values.

ADD REPLY
0
Entering edit mode

Thanks a lot, RamRS, it's such a great help. Going forward, I have tried your solution and used the following code

bulk_clean<- tidyr::pivot_wider(bulk,id_cols=patient_id,gene_code)

but i m not getting the desired output, please let me know where i am going wrong. thanks again.

ADD REPLY
0
Entering edit mode

What is the output you're getting? Also, please give us the output to: dput(head(bulk, 25)).

ADD REPLY
0
Entering edit mode

Hello David_emir!

It appears that your post has been cross-posted to another site: https://bioinformatics.stackexchange.com/questions/14734/gene-expression-table-to-expression-matrix-converstion

This is typically not recommended as it runs the risk of annoying people in both communities.

ADD REPLY
0
Entering edit mode

Thanks you RamRS will keep that in mind.

ADD REPLY
2
Entering edit mode
3.5 years ago
Alex Nesmelov ▴ 200
 library(tidyverse)
 your_data %>%
 select(patient_id, gene_code, gene_raw) %>%
 pivot_wider(names_from = patient_id, 
          values_from = gene_raw)

Switch gene_raw to some other expression value if you need.

ADD COMMENT
0
Entering edit mode

Thanks a lot, It worked like a charm

ADD REPLY

Login before adding your answer.

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