-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #106 from nf-core/common-quantification
Implement common quantification
- Loading branch information
Showing
93 changed files
with
3,849 additions
and
520 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
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import pandas as pd | ||
import os | ||
|
||
parser = argparse.ArgumentParser(description='Merge quantification files into a single file') | ||
parser.add_argument('--inputs', type=str, nargs='+', help='List input files to merge') | ||
parser.add_argument('--output', type=str, help='Path to output combined quantification file') | ||
|
||
args = parser.parse_args() | ||
|
||
dfs = [pd.read_csv(f, sep='\t', index_col=[0, 1]) for f in args.inputs] | ||
df_combined = pd.concat(dfs, axis=1, sort=True) | ||
|
||
df_combined.to_csv(args.output, sep='\t') |
This file was deleted.
Oops, something went wrong.
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,31 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import argparse | ||
import pandas as pd | ||
import os | ||
|
||
parser = argparse.ArgumentParser(description='Merge counts across tools for a single sample') | ||
parser.add_argument('--beds', type=str, nargs='+', help='List of bed files to merge') | ||
parser.add_argument('--out_bed', type=str, help='Output bed file') | ||
parser.add_argument('--out_tsv', type=str, help='Output tsv file') | ||
|
||
args = parser.parse_args() | ||
|
||
columns = ['chr', 'start', 'end', 'strand', 'count', 'tools'] | ||
dfs = {os.path.basename(bed).split('.')[0]: pd.read_csv(bed, | ||
sep='\t', | ||
header=None, | ||
names=columns, | ||
index_col=[0, 1, 2, 3]) | ||
.drop('tools', axis=1) for bed in args.beds} | ||
|
||
dfs = [df.rename(columns={'count': sample}) for sample, df in dfs.items()] | ||
|
||
df = pd.concat(dfs, axis=1) | ||
df = df.fillna(0).astype(int) | ||
|
||
df.to_csv(args.out_bed, sep='\t') | ||
|
||
df.index = df.index.map(lambda x: f'{x[0]}:{x[1]}-{x[2]}:{x[3]}') | ||
df.index.name = 'ID' | ||
df.to_csv(args.out_tsv, sep='\t') |
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 python3 | ||
|
||
import argparse | ||
import pandas as pd | ||
|
||
parser = argparse.ArgumentParser(description='Merge counts across tools for a single sample') | ||
parser.add_argument('--beds', type=str, nargs='+', help='List of bed files to merge') | ||
parser.add_argument('--tool_filter', type=int, help='Minimum number of tools to keep a circRNA') | ||
parser.add_argument('--duplicates_fun', type=str, help='Function to apply to duplicates', choices=['sum', 'mean', 'max', 'min']) | ||
parser.add_argument('--output', type=str, help='Output file') | ||
|
||
args = parser.parse_args() | ||
|
||
columns = ['chr', 'start', 'end', 'strand', 'count'] | ||
dfs = [pd.read_csv(bed, sep='\t', header=None, names=columns) for bed in args.beds] | ||
df = pd.concat(dfs) | ||
|
||
df['tool_count'] = 1 | ||
|
||
df = df.groupby(['chr', 'start', 'end', 'strand']).agg({'count': args.duplicates_fun, | ||
'tool_count': 'sum'}).reset_index() | ||
df = df[df['tool_count'] >= args.tool_filter] | ||
|
||
df.to_csv(args.output, sep='\t', index=False, header=False) |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.