Commit 233c7a4e authored by Blaise Li's avatar Blaise Li
Browse files

Avoiding deprecation warnings.

parent 32a603f1
......@@ -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")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment