Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libhts
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
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
Blaise LI
libhts
Commits
4d3532cc
Commit
4d3532cc
authored
7 years ago
by
Blaise Li
Browse files
Options
Downloads
Patches
Plain Diff
Fix error in DE status determination.
parent
93f8a8e1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libhts/__init__.py
+1
-1
1 addition, 1 deletion
libhts/__init__.py
libhts/libhts.py
+22
-2
22 additions, 2 deletions
libhts/libhts.py
with
23 additions
and
3 deletions
libhts/__init__.py
+
1
−
1
View file @
4d3532cc
from
.libhts
import
do_deseq2
,
median_ratio_to_pseudo_ref_size_factors
,
status_setter
from
.libhts
import
do_deseq2
,
median_ratio_to_pseudo_ref_size_factors
,
size_factor_correlations
,
status_setter
This diff is collapsed.
Click to expand it.
libhts/libhts.py
+
22
−
2
View file @
4d3532cc
...
...
@@ -9,6 +9,8 @@ def formatwarning(message, category, filename, lineno, line):
warnings
.
formatwarning
=
formatwarning
import
pandas
as
pd
# To compute correlation coefficient
from
scipy.stats.stats
import
pearsonr
# To compute geometric mean
from
scipy.stats.mstats
import
gmean
from
rpy2.robjects
import
r
,
pandas2ri
,
Formula
,
StrVector
...
...
@@ -97,6 +99,22 @@ def median_ratio_to_pseudo_ref_size_factors(counts_data):
return
counts_data
[
counts_data
.
prod
(
axis
=
1
)
>
0
].
apply
(
median_ratio_to_pseudo_ref
,
axis
=
0
)
def
size_factor_correlations
(
counts_data
,
summaries
,
normalizer
):
"""
Is there a correlation, across libraries, between normalized values and size factors?
The size factor type *normalizer* is either computed or taken from *summaries*.
The normalized data are computed by dividing *counts_data* by this size factor.
"""
if
normalizer
==
"
median_ratio_to_pseudo_ref
"
:
size_factors
=
median_ratio_to_pseudo_ref_size_factors
(
counts_data
)
else
:
size_factors
=
summaries
.
loc
[
normalizer
]
#by_norm = counts_data / size_factors
def
compute_pearsonr_with_size_factor
(
row
):
return
pearsonr
(
row
,
size_factors
)[
0
]
#return by_norm.apply(compute_pearsonr_with_size_factor, axis=1)
return
(
counts_data
/
size_factors
).
apply
(
compute_pearsonr_with_size_factor
,
axis
=
1
)
def
status_setter
(
lfc_cutoffs
=
None
):
if
lfc_cutoffs
is
None
:
lfc_cutoffs
=
[
0.5
,
1
,
2
]
...
...
@@ -107,13 +125,15 @@ def status_setter(lfc_cutoffs=None):
#if row["log2FoldChange"] > 0:
lfc
=
row
[
"
lfcMLE
"
]
if
lfc
>
0
:
# Start from the highest cutoff,
# and decrease until below lfc
for
cutoff
in
sorted
(
lfc_cutoffs
,
reverse
=
True
):
if
lfc
>
cutoff
:
return
f
"
up
{
cutoff
}
"
return
"
up
"
else
:
for
cutoff
in
sorted
(
lfc_cutoffs
):
if
lfc
<
cutoff
:
for
cutoff
in
sorted
(
lfc_cutoffs
,
reverse
=
True
):
if
lfc
<
-
cutoff
:
return
f
"
down
{
cutoff
}
"
return
"
down
"
else
:
...
...
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