-
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.
- Rewrote count collation to collate counts across all samples - Added two simulated samples to test multi-sample collation - top-level sample name now carried through to count matrix
- Loading branch information
Showing
10 changed files
with
111 additions
and
42 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,52 @@ | ||
#!/usr/bin/env python | ||
''' | ||
Module : collate_counts | ||
Description : Collate multiple count files into one sorted table | ||
Copyright : (c) WEHI Genomics R&D, 2024 | ||
License : TBD | ||
Maintainer : Marek Cmero | ||
Portability : POSIX | ||
''' | ||
import pandas as pd | ||
from natsort import index_natsorted, order_by_index | ||
from argparse import ArgumentParser | ||
|
||
|
||
def parse_args(): | ||
'''Parse arguments''' | ||
description = ''' | ||
Count guide sequences | ||
Usage: | ||
collate_counts.py <count_files> | ||
Outputs a table of merged counts | ||
''' | ||
parser = ArgumentParser(description=description) | ||
parser.add_argument('count_files', | ||
nargs='+', | ||
type=str, | ||
help='Count files to merge') | ||
|
||
return parser.parse_args() | ||
|
||
|
||
def main(): | ||
args = parse_args() | ||
|
||
result_df = pd.DataFrame() | ||
for count_file in args.count_files: | ||
df = pd.read_csv(count_file, sep='\t') | ||
|
||
if len(result_df) == 0: | ||
result_df = df | ||
else: | ||
result_df = pd.merge(result_df, df, how='outer', on='guide') | ||
|
||
new_index = order_by_index(result_df.index, index_natsorted(df['guide'])) | ||
result_df = result_df.reindex(index=new_index) | ||
print(result_df.to_string(index=False)) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
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 |
---|---|---|
|
@@ -5,4 +5,6 @@ channels: | |
dependencies: | ||
- biopython | ||
- python-edlib | ||
- pandas | ||
- natsort | ||
|
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