Commit 30c43b85 authored by Simon CHEVOLLEAU's avatar Simon CHEVOLLEAU 💻
Browse files

Add convert_ensg_to_gene function

parent 118cdd0a
......@@ -448,3 +448,29 @@ plotMultipleOneDimension <- function(table, pseudotimes, dir_path, colors = NULL
}
return(plots)
}
convert_ensg_to_gene <- function(dt) {
library(biomaRt)
mart <- useMart(biomart = "ensembl", dataset = "hsapiens_gene_ensembl")
transcript_ids <- rownames(dt)
res <- getBM(attributes = c('ensembl_transcript_id_version',
'ensembl_gene_id',
'external_transcript_name',
'external_gene_name'),
filters = 'external_transcript_name',
values = transcript_ids,
mart = mart)
dt <- cbind("ensembl_transcript_id_version"=rownames(dt), dt)
library(dplyr)
dt <- right_join(res, dt, by = c("ensembl_transcript_id_version"="ensembl_transcript_id_version"))
writeTable(dt, "counts_unconcatenated.tsv")
dt <- dt[,4:ncol(dt)]
dt <- aggregate(. ~ external_gene_name, data=dt, FUN=sum)
countsTable <- dt[, 2:ncol(dt)]
rownames(countsTable) <- dt$external_gene_name
if (rownames(countsTable)[1] == ""){countsTable <- countsTable[2:nrow(countsTable),]}
return (countsTable)
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment