-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: switch to featureCounts. It is much faster than htseq-count and…
… works with alignment sorted BAM files (even though internally it sorts by name to work) fix: no need for virtual environment in defaults as PBS can pass environment variables to jobs.
- Loading branch information
Showing
2 changed files
with
27 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/env python | ||
|
||
import pandas as pd | ||
import json | ||
import os | ||
import argparse | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
parser = argparse.ArgumentParser(description='This script will collect the counts generated by featureCounts. Outputs 2 files: one for read counts and one for stats.') | ||
|
||
parser.add_argument('-p', '--project-path', help='Path to project folder') | ||
parser.add_argument('-g', '--groups-json', help='json file for experiment setup with full path.') | ||
parser.add_argument('-o', '--output', help='Path and prefix of output file. e.g.: ./htseq/collected_counts') | ||
args = parser.parse_args() | ||
|
||
groups = json.load(open(args.groups_json, 'r')) | ||
|
||
df = pd.concat([pd.io.parsers.read_table(os.path.join(os.path.abspath(args.project_path), sample, 'htseq_counts.out'), header=None, index_col=0, names=[sample]) for group in groups.values() for sample in group.keys()], axis=1) | ||
df_stats = df.tail(5).copy() | ||
df = df.drop(df.tail(5).index) | ||
df.to_csv('{}.csv'.format(args.output)) | ||
df_stats.to_csv('{}_stats.csv'.format(args.output)) |