Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Transcript sampler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
zavolan_group
tools
Transcript sampler
Commits
6b25546e
Commit
6b25546e
authored
2 years ago
by
Hugo Gillet
Browse files
Options
Downloads
Patches
Plain Diff
Update match_reprtranscript_expressionlevel.py
parent
add405d4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/match_reprtranscript_expressionlevel.py
+11
-10
11 additions, 10 deletions
scripts/match_reprtranscript_expressionlevel.py
with
11 additions
and
10 deletions
scripts/match_reprtranscript_expressionlevel.py
+
11
−
10
View file @
6b25546e
### Made by Hugo Gillet ###
### Made by Hugo Gillet ###
import
pandas
as
pd
import
pandas
as
pd
import
json
import
json
import
re
import
representative
as
repr
import
representative
as
repr
import
os
def
dict_reprTrans_to_df
(
dict_reprTrans
:
dict
[
str
,
str
])
->
pd
.
DataFrame
:
def
dict_reprTrans_to_df
(
dict_reprTrans
:
dict
[
str
,
str
])
->
pd
.
DataFrame
:
...
@@ -169,12 +167,14 @@ def match_byGene(
...
@@ -169,12 +167,14 @@ def match_byGene(
return
df_clean
return
df_clean
def
output_tsv
(
dataframe
:
pd
.
DataFrame
)
->
pd
.
DataFrame
:
def
output_tsv
(
dataframe
:
pd
.
DataFrame
,
output_path
:
str
)
->
str
:
"""
Convert pandas dataframe into a tsv file
"""
Convert pandas dataframe into a tsv file
Args:
Args:
dataframe
(str)
: Pandas dataframe containing
dataframe : Pandas dataframe containing
representative transcripts and their expression level
representative transcripts and their expression level
output_path : path indicating were the tsv file should be written
Returns:
Returns:
Tsv file containing representative transcripts
Tsv file containing representative transcripts
...
@@ -186,10 +186,10 @@ def output_tsv(dataframe: pd.DataFrame) -> pd.DataFrame:
...
@@ -186,10 +186,10 @@ def output_tsv(dataframe: pd.DataFrame) -> pd.DataFrame:
pass
pass
csv_file
=
dataframe
.
to_csv
(
csv_file
=
dataframe
.
to_csv
(
o
s
.
getcwd
()
+
"
\ReprTrans_ExpressionLevel.tsv
"
,
o
utput_path
,
sep
=
"
\t
"
,
sep
=
"
\t
"
,
index
=
False
,
index
=
False
,
header
=
Fals
e
,
header
=
Tru
e
,
)
)
return
csv_file
return
csv_file
...
@@ -198,7 +198,7 @@ def output_tsv(dataframe: pd.DataFrame) -> pd.DataFrame:
...
@@ -198,7 +198,7 @@ def output_tsv(dataframe: pd.DataFrame) -> pd.DataFrame:
def
match_reprTranscript_expressionLevel
(
def
match_reprTranscript_expressionLevel
(
exprTrans
:
str
,
dict_reprTrans
:
dict
,
intermediate_file
:
str
exprTrans
:
str
,
dict_reprTrans
:
dict
,
intermediate_file
:
str
,
):
):
"""
Combine functions to replace transcripts from an expression level csv/tsv file
"""
Combine functions to replace transcripts from an expression level csv/tsv file
with representative transcripts
with representative transcripts
...
@@ -210,6 +210,7 @@ def match_reprTranscript_expressionLevel(
...
@@ -210,6 +210,7 @@ def match_reprTranscript_expressionLevel(
representative transcipt
representative transcipt
intemediate_file (str) : txt file containing genes, transcript
intemediate_file (str) : txt file containing genes, transcript
and their expression level from the transkript_extractor function
and their expression level from the transkript_extractor function
output_path : path indicating were the tsv file should be written
Returns:
Returns:
tsv file of representative trasncripts and their expression level
tsv file of representative trasncripts and their expression level
...
@@ -221,10 +222,10 @@ def match_reprTranscript_expressionLevel(
...
@@ -221,10 +222,10 @@ def match_reprTranscript_expressionLevel(
df_geneTrans
=
transcripts_by_gene_inDf
(
df_intermediate
)
df_geneTrans
=
transcripts_by_gene_inDf
(
df_intermediate
)
df_exprTrans
=
tsv_or_csv_to_df
(
exprTrans
)
df_exprTrans
=
tsv_or_csv_to_df
(
exprTrans
)
df_reprTrans
=
dict_reprTrans_to_df
(
dict_reprTrans
)
df_reprTrans
=
dict_reprTrans_to_df
(
dict_reprTrans
)
df_exprLevel_byGene
=
exprLevel_byGene
(
df_exprTrans
,
df_geneTrans
)
df_exprLevel_byGene
=
exprLevel_byGene
(
df_exprTrans
,
df_geneTrans
)
df_match
=
match_byGene
(
df_reprTrans
,
df_exprLevel_byGene
)
df_match
=
match_byGene
(
df_reprTrans
,
df_exprLevel_byGene
)
output
=
output_tsv
(
df_match
)
df_match
.
rename
(
columns
=
{
'
reprTrans
'
:
'
id
'
,
'
Expression_level
'
:
'
level
'
},
inplace
=
True
)
return
output
return
df_match
# run the programm
# run the programm
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment