Bioinformatics Asked on May 10, 2021
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
Your question stated differently is as follows:
I have data in long format and need to change it to wide format. For that, I want to keep the
gene_raw
, usepatient_id
for the column names andgene_code
for the row names. How can I do this easily?
Assuming you know how to read that into R as a data.frame that I'll call d
:
library(tidyr)
library(dplyr)
reformatted = d %>% select(patient_id, gene_code, gene_raw) %>% spread(patient_id, gene_raw) %>% column_to_rownames(gene_code)
Or something along those lines.
Correct answer by Devon Ryan on May 10, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP