Skip to content
Snippets Groups Projects
Commit 233c7a4e authored by Blaise Li's avatar Blaise Li
Browse files

Avoiding deprecation warnings.

parent 32a603f1
No related branches found
No related tags found
No related merge requests found
...@@ -245,7 +245,7 @@ def sum_htseq_counts(counts_filename): ...@@ -245,7 +245,7 @@ def sum_htseq_counts(counts_filename):
def read_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", ["__no_feature",
"__ambiguous", "__ambiguous",
"__too_low_aQual", "__too_low_aQual",
...@@ -260,11 +260,11 @@ def sum_feature_counts(counts_filename, nb_bams=1): ...@@ -260,11 +260,11 @@ def sum_feature_counts(counts_filename, nb_bams=1):
This determines which columns should be used.""" This determines which columns should be used."""
# Counts are in the 7-th column, starting from third row. # Counts are in the 7-th column, starting from third row.
# The first sum is over the the rows, the second over the columns # 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): 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 # I 3746 3909 "WBGene00023193" - . 17996
...@@ -281,7 +281,7 @@ def sum_intersect_counts(counts_filename): ...@@ -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.""" """Sums all counts in a bedtools intersect generated *counts_filename*, where the annotation was in bed format."""
# Counts are in the 7-th column # Counts are in the 7-th column
try: 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: except pd.errors.EmptyDataError:
return "NA" return "NA"
...@@ -289,7 +289,7 @@ def read_intersect_counts(counts_filename): ...@@ -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): # index_col takes effect after column selection with usecols, hence index_col=0 (ex-third column):
# https://stackoverflow.com/a/45943627/1878788 # https://stackoverflow.com/a/45943627/1878788
try: 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: except pd.errors.EmptyDataError:
return pd.DataFrame(index = [], columns = ["gene", "counts"]).set_index("gene") return pd.DataFrame(index = [], columns = ["gene", "counts"]).set_index("gene")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment