Skip to content
GitLab
Menu
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
233c7a4e
Commit
233c7a4e
authored
Apr 15, 2019
by
Blaise Li
Browse files
Avoiding deprecation warnings.
parent
32a603f1
Changes
1
Hide whitespace changes
Inline
Side-by-side
libworkflows/libworkflows/libworkflows.py
View file @
233c7a4e
...
...
@@ -245,7 +245,7 @@ def sum_htseq_counts(counts_filename):
def
read_htseq_counts
(
counts_filename
):
return
pd
.
read_
table
(
counts_filename
,
header
=
None
,
index_col
=
0
).
drop
(
return
pd
.
read_
csv
(
counts_filename
,
sep
=
"
\t
"
,
header
=
None
,
index_col
=
0
).
drop
(
[
"__no_feature"
,
"__ambiguous"
,
"__too_low_aQual"
,
...
...
@@ -260,11 +260,11 @@ def sum_feature_counts(counts_filename, nb_bams=1):
This determines which columns should be used."""
# Counts are in the 7-th column, starting from third row.
# The first sum is over the the rows, the second over the columns
return
pd
.
read_
table
(
counts_filename
,
skiprows
=
2
,
usecols
=
range
(
6
,
6
+
nb_bams
),
header
=
None
).
sum
().
sum
()
return
pd
.
read_
csv
(
counts_filename
,
sep
=
"
\t
"
,
skiprows
=
2
,
usecols
=
range
(
6
,
6
+
nb_bams
),
header
=
None
).
sum
().
sum
()
def
read_feature_counts
(
counts_filename
,
nb_bams
=
1
):
return
pd
.
read_
table
(
counts_filename
,
skiprows
=
1
,
usecols
=
[
0
,
*
range
(
6
,
6
+
nb_bams
)],
index_col
=
0
)
return
pd
.
read_
csv
(
counts_filename
,
sep
=
"
\t
"
,
skiprows
=
1
,
usecols
=
[
0
,
*
range
(
6
,
6
+
nb_bams
)],
index_col
=
0
)
# I 3746 3909 "WBGene00023193" - . 17996
...
...
@@ -281,7 +281,7 @@ def sum_intersect_counts(counts_filename):
"""Sums all counts in a bedtools intersect generated *counts_filename*, where the annotation was in bed format."""
# Counts are in the 7-th column
try
:
return
pd
.
read_
table
(
counts_filename
,
usecols
=
[
6
],
header
=
None
).
sum
().
iloc
[
0
]
return
pd
.
read_
csv
(
counts_filename
,
sep
=
"
\t
"
,
usecols
=
[
6
],
header
=
None
).
sum
().
iloc
[
0
]
except
pd
.
errors
.
EmptyDataError
:
return
"NA"
...
...
@@ -289,7 +289,7 @@ def read_intersect_counts(counts_filename):
# index_col takes effect after column selection with usecols, hence index_col=0 (ex-third column):
# https://stackoverflow.com/a/45943627/1878788
try
:
return
pd
.
read_
table
(
counts_filename
,
usecols
=
[
3
,
6
],
header
=
None
,
index_col
=
0
)
return
pd
.
read_
csv
(
counts_filename
,
sep
=
"
\t
"
,
usecols
=
[
3
,
6
],
header
=
None
,
index_col
=
0
)
except
pd
.
errors
.
EmptyDataError
:
return
pd
.
DataFrame
(
index
=
[],
columns
=
[
"gene"
,
"counts"
]).
set_index
(
"gene"
)
...
...
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