Skip to content

Commit 5a5d023

Browse files
authored
Merge pull request #10 from break-through-cancer/fix_tests
Fix tests
2 parents b944696 + d07a447 commit 5a5d023

File tree

17 files changed

+102
-191
lines changed

17 files changed

+102
-191
lines changed

.cirro/process-form.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,6 @@
1515
"type": "boolean",
1616
"value": true
1717
},
18-
"cluster_lvl": {
19-
"default": true,
20-
"description": "Clone clustering analysis with GLIPH2",
21-
"title": "Cluster",
22-
"type": "boolean",
23-
"value": true
24-
},
2518
"kmer_min_depth": {
2619
"default": "3",
2720
"description": "minimum depth of k-mer during clustering (GLIPH2)",

.cirro/process-input.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"sample_lvl": "$.params.dataset.paramJson.sample_lvl",
33
"compare_lvl": "$.params.dataset.paramJson.compare_lvl",
4-
"cluster_lvl": "$.params.dataset.paramJson.cluster_lvl",
54
"data_dir": "$.params.inputs[0].s3|/data/",
65
"kmer_min_depth": "$.params.dataset.paramJson.kmer_min_depth",
76
"local_min_OVE": "$.params.dataset.paramJson.local_min_OVE",

bin/calc_compare.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828
# metavar='meta_data',
2929
# type=str,
3030
# help='metadata CSV file initially passed to nextflow run command')
31-
parser.add_argument('-p', '--project_dir',
32-
metavar='project_dir',
31+
parser.add_argument('-d', '--data_dir',
32+
metavar='data_dir',
3333
type=str,
34-
help='path to project directory')
34+
help='path to data directory')
3535

3636
args = parser.parse_args()
3737

3838
## Import project directory path
39-
project_dir = args.project_dir
40-
sys.path.append(project_dir + '/bin/')
39+
data_dir = args.data_dir
40+
4141
from utils import jaccard_index, sorensen_index, morisita_horn_index #, jensen_shannon_distance
4242

4343
## Read in sample table CSV file
@@ -59,6 +59,8 @@
5959
dfs = {}
6060
for file in files:
6161
# load data
62+
file = os.path.basename(file)
63+
file = os.path.join(data_dir, file)
6264
df = pd.read_csv(file, sep='\t', header=0)
6365

6466
# Rename columns

bin/calc_sample.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from scipy.stats import entropy
1414
import numpy as np
1515
import csv
16+
import os
1617

1718
# initialize parser
1819
parser = argparse.ArgumentParser(description='Calculate clonality of a TCR repertoire')
@@ -26,10 +27,6 @@
2627
metavar='count_table',
2728
type=argparse.FileType('r'),
2829
help='counts file in TSV format')
29-
# parser.add_argument('-d', '--data_dir',
30-
# metavar='data_dir',
31-
# type=str,
32-
# help='path to data directory')
3330

3431
args = parser.parse_args()
3532

bin/prep_gliph2_tcr.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,11 @@
2929
print("samplesheet: ", args.samplesheet)
3030

3131
samplesheet = pd.read_csv(args.samplesheet, header=0)
32-
data_dir = args.data_dir + "/"
33-
tsv_files = glob.glob(os.path.join(data_dir, "*.tsv"))
34-
tsv_files = [os.path.abspath(file) for file in tsv_files]
3532

3633
dfs = []
3734
for index, row in samplesheet.iterrows():
38-
file_path = row['file']
35+
file_path = os.path.basename(row['file'])
36+
file_path = os.path.join(args.data_dir, file_path)
3937
print(f"Loading {file_path}")
4038

4139
# Read the TSV file into a dataframe

bin/samplesheet.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env python
2+
3+
import argparse
4+
import os
5+
import pandas as pd
6+
7+
# initialize parser
8+
parser = argparse.ArgumentParser()
9+
parser.add_argument('-s', '--samplesheet',
10+
metavar='samplesheet',
11+
type=str,
12+
help='sample metadata passed in through samples CSV file')
13+
14+
parser.add_argument('-d', '--data_dir',
15+
metavar='data_dir',
16+
type=str,
17+
help='path to data directory')
18+
19+
args = parser.parse_args()
20+
21+
#do any processing of the samplesheet here
22+
def samplesheet(samplesheet, data_dir):
23+
ss = pd.read_csv(samplesheet, sep=',')
24+
ss.to_csv('samplesheet_utf8.csv', index=False, encoding='utf-8-sig')
25+
26+
stats = ss.describe()
27+
stats.to_csv('samplesheet_stats.csv', index=False, encoding='utf-8-sig')
28+
29+
print(ss.head())
30+
31+
samplesheet(args.samplesheet, args.data_dir)
32+

modules/local/compare_calc.nf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ process COMPARE_CALC {
1515
"""
1616
calc_compare.py \
1717
-s $sample_utf8 \
18-
-p $projectDir
18+
-d $data_dir
1919
"""
2020
}

modules/local/sample_calc.nf

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ process SAMPLE_CALC {
1616
script:
1717
"""
1818
echo '' > sample_stats.csv
19-
20-
calc_sample.py \
21-
-s '${sample_meta}' \
22-
-c ${count_table}
19+
calc_sample.py -s '${sample_meta}' -c ${count_table}
2320
"""
2421

2522
stub:

modules/local/samplesheet_check.nf

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@ process SAMPLESHEET_CHECK {
88

99
output:
1010
path 'samplesheet_utf8.csv' , emit: samplesheet_utf8
11-
path 'samplesheet_stats.txt'
11+
path 'samplesheet_stats.csv'
1212

1313
script:
1414
"""
15-
#!/bin/bash
16-
17-
iconv -t utf-8 $samplesheet > samplesheet_utf8.csv
18-
19-
csvstat samplesheet_utf8.csv > samplesheet_stats.txt
15+
samplesheet.py -s $samplesheet -d ${params.data_dir}
2016
"""
2117

2218
stub:

subworkflows/local/cluster.nf

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)