Skip to content

Commit

Permalink
Merge pull request #72 from miRTop/dev
Browse files Browse the repository at this point in the history
attempt to fix missing keys in logs
  • Loading branch information
lpantano authored Apr 21, 2022
2 parents bb6a810 + 212e1c7 commit 170de82
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
0.4.25

* [fix outliers samples](https://github.com/nf-core/smrnaseq/issues/137). When there is no identification of reference sequences or isomirs, the multiqc module will fails because it won't find the expected keys. Adding 0 when is the case.

0.4.24

* [fix bad](https://github.com/miRTop/mirtop/issues/64) annotation when 5 or more T/A at the end of the sequence by @DrHogart
Expand Down
17 changes: 17 additions & 0 deletions mirtop/gff/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,20 @@ def _classify(srna_type, attr, samples):
return lines


def _add_missing(df):
# ref_miRNA_mean
category = "ref_miRNA_mean"
if sum(df['category']==category) == 0:
df2 = {'category': category, 'sample': df['sample'].iat[0], 'counts': 0}
df = df.append(df2, ignore_index = True)

category = "isomiR_sum"
if sum(df['category']==category) == 0:
df2 = {'category': category, 'sample': df['sample'].iat[0], 'counts': 0}
df = df.append(df2, ignore_index = True)

return df

def _summary(lines):
"""
Summarize long table according to thresholds
Expand All @@ -113,10 +127,13 @@ def _summary(lines):
df.counts = df.counts.astype(int)
df_sum = df.groupby(['category', 'sample'], as_index=False).sum()
df_sum['category'] = ["%s_sum" % r for r in df_sum['category']]
df_sum = _add_missing(df_sum)
df_count = df.groupby(['category', 'sample'], as_index=False).count()
df_count['category'] = ["%s_count" % r for r in df_count['category']]
df_count = _add_missing(df_count)
df_mean = df.groupby(['category', 'sample'], as_index=False).mean()
df_mean['category'] = ["%s_mean" % r for r in df_mean['category']]
df_mean = _add_missing(df_mean)
df = pd.concat([df_sum, df_count, df_mean])
return df

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
from setuptools import setup, find_packages

version = '0.4.24'
version = '0.4.25'

url = 'http://github.com/mirtop/mirtop'

Expand Down

0 comments on commit 170de82

Please sign in to comment.