Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simon CHEVOLLEAU
Embryo functions
Commits
30c43b85
Commit
30c43b85
authored
Mar 28, 2022
by
Simon CHEVOLLEAU
💻
Browse files
Add convert_ensg_to_gene function
parent
118cdd0a
Changes
1
Hide whitespace changes
Inline
Side-by-side
functions.R
View file @
30c43b85
...
...
@@ -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
)
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment