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
d1b17ada
Commit
d1b17ada
authored
2 years ago
by
Jakob Rien
Browse files
Options
Downloads
Patches
Plain Diff
Replace poisson_sampling.py
parent
05453696
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/poisson_sampling.py
+12
-2
12 additions, 2 deletions
scripts/poisson_sampling.py
with
12 additions
and
2 deletions
scripts/poisson_sampling.py
+
12
−
2
View file @
d1b17ada
### Called Packages ###
import
pandas
as
pd
import
pandas
as
pd
import
numpy
as
np
import
numpy
as
np
import
argparse
import
argparse
import
transcript_extractor
as
te
python_version
=
"
3.7.13
"
module_list
=
[
pd
,
np
,
argparse
]
modul_name_list
=
[
"
pd
"
,
"
np
"
,
"
argparse
"
]
### Functions ###
'''
'''
Sample transcript
Sample transcript
...
@@ -16,11 +23,13 @@ output: csv file with gene id and count
...
@@ -16,11 +23,13 @@ output: csv file with gene id and count
'''
'''
def
transcript_sampling
(
total_transcript_number
,
csv_file
,
output_csv
):
def
transcript_sampling
(
total_transcript_number
,
df_repr
,
output_csv
):
df
=
pd
.
read_csv
(
csv_file
,
sep
=
'
\t
'
,
lineterminator
=
'
\n
'
,
names
=
[
"
id
"
,
"
level
"
])
#df = pd.read_csv(csv_file, sep="\t", lineterminator="\n", names=["id", "level"])
df
=
df_repr
# the function "match_reprTranscript_expressionLevel()" now directly output a dataframe
levels
=
[]
levels
=
[]
sums
=
df
[
'
level
'
].
tolist
()
sums
=
df
[
'
level
'
].
tolist
()
total
=
sum
(
sums
)
total
=
sum
(
sums
)
total_transcript_number
=
int
(
total_transcript_number
)
# I added this because writting a number in the terminal inputed a string
normalized
=
total_transcript_number
/
total
normalized
=
total_transcript_number
/
total
for
expression_level
in
df
[
'
level
'
]:
for
expression_level
in
df
[
'
level
'
]:
poisson_sampled
=
np
.
random
.
poisson
(
expression_level
*
normalized
)
poisson_sampled
=
np
.
random
.
poisson
(
expression_level
*
normalized
)
...
@@ -30,6 +39,7 @@ def transcript_sampling(total_transcript_number, csv_file, output_csv):
...
@@ -30,6 +39,7 @@ def transcript_sampling(total_transcript_number, csv_file, output_csv):
pd
.
DataFrame
.
to_csv
(
transcript_numbers
,
output_csv
)
pd
.
DataFrame
.
to_csv
(
transcript_numbers
,
output_csv
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
#te.version_control(module_list,modul_name_list,python_version)
parser
=
argparse
.
ArgumentParser
(
parser
=
argparse
.
ArgumentParser
(
description
=
"
Transcript Poisson sampler, csv output
"
,
description
=
"
Transcript Poisson sampler, csv output
"
,
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
formatter_class
=
argparse
.
ArgumentDefaultsHelpFormatter
...
...
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