Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Blaise LI
bioinfo_utils
Commits
bfcb15fc
Commit
bfcb15fc
authored
May 13, 2019
by
Blaise Li
Browse files
Trying to fix garbage collection issues.
When R crashes, rpy doesn't seem to handle this properly.
parent
c04ad30a
Changes
1
Hide whitespace changes
Inline
Side-by-side
libdeseq/libdeseq/libdeseq.py
View file @
bfcb15fc
...
...
@@ -14,6 +14,7 @@ as_df = r("as.data.frame")
from
rpy2.rinterface
import
RRuntimeError
from
rpy2.robjects.packages
import
importr
deseq2
=
importr
(
"DESeq2"
)
#import gc
def
do_deseq2
(
cond_names
,
conditions
,
counts_data
,
...
...
@@ -65,6 +66,7 @@ def do_deseq2(cond_names, conditions, counts_data,
# raise
try
:
dds
=
deseq2
.
estimateSizeFactors_DESeqDataSet
(
dds
,
type
=
"ratio"
)
#gc.collect()
except
RRuntimeError
as
e
:
if
sum
(
counts_data
.
prod
(
axis
=
1
))
==
0
:
msg
=
""
.
join
([
"Error occurred in estimateSizeFactors:
\n
%s
\n
"
%
e
,
...
...
@@ -73,10 +75,12 @@ def do_deseq2(cond_names, conditions, counts_data,
warnings
.
warn
(
msg
)
try
:
dds
=
deseq2
.
estimateSizeFactors_DESeqDataSet
(
dds
,
type
=
"poscounts"
)
#gc.collect()
except
RRuntimeError
as
e
:
msg
=
""
.
join
([
"Error occurred in estimateSizeFactors:
\n
%s
\n
"
%
e
,
"We give up."
])
warnings
.
warn
(
msg
)
#gc.collect()
raise
#print(counts_data.dtypes)
#print(counts_data.columns)
...
...
@@ -91,24 +95,29 @@ def do_deseq2(cond_names, conditions, counts_data,
#pd.DataFrame({cond : size_factors.loc[cond][0] for cond in COND_NAMES}, index=('size_factor',))
try
:
dds
=
deseq2
.
estimateDispersions_DESeqDataSet
(
dds
,
fitType
=
"parametric"
)
#gc.collect()
except
RRuntimeError
as
e
:
msg
=
""
.
join
([
"Error occurred in estimateDispersions:
\n
%s
\n
"
%
e
,
"We will try with fitType=
\"
local
\"
."
])
warnings
.
warn
(
msg
)
try
:
dds
=
deseq2
.
estimateDispersions_DESeqDataSet
(
dds
,
fitType
=
"local"
)
#gc.collect()
except
RRuntimeError
as
e
:
msg
=
""
.
join
([
"Error occurred in estimateDispersions:
\n
%s
\n
"
%
e
,
"We will try with fitType=
\"
mean
\"
."
])
warnings
.
warn
(
msg
)
try
:
dds
=
deseq2
.
estimateDispersions_DESeqDataSet
(
dds
,
fitType
=
"mean"
)
#gc.collect()
except
RRuntimeError
as
e
:
msg
=
""
.
join
([
"Error occurred in estimateDispersions:
\n
%s
\n
"
%
e
,
"We give up."
])
warnings
.
warn
(
msg
)
#gc.collect()
raise
dds
=
deseq2
.
nbinomWaldTest
(
dds
,
betaPrior
=
deseq2_args
[
"betaPrior"
])
#gc.collect()
res
=
pandas2ri
.
ri2py
(
as_df
(
deseq2
.
results
(
dds
,
contrast
=
contrast
,
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment