Skip to content

Commit

Permalink
Add --infercnv_delimiter argument
Browse files Browse the repository at this point in the history
Former-commit-id: d2573fa
  • Loading branch information
eweitz committed Mar 29, 2018
1 parent 5cf02cf commit 694cd88
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions scripts/matrix_to_ideogram_annots.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@

class MatrixToIdeogramAnnots:

def __init__(self, infercnv_output, gen_pos_file, clusters_meta,
output_file):
def __init__(self, infercnv_output, infercnv_delimiter, gen_pos_file,
clusters_meta, output_file):
"""Class and parameter docs in module summary and argument parser"""

self.infercnv_output = infercnv_output
self.infercnv_delimiter = infercnv_delimiter
self.clusters = self.get_clusters(clusters_meta)
self.output_file = output_file
self.genomic_position_file_path = gen_pos_file
Expand Down Expand Up @@ -121,7 +122,8 @@ def get_expression_matrix_dict(self):

cells_dict = {}

cells_list = lines[0].strip().split()
cells_list = lines[0].strip().split(self.infercnv_delimiter)

for i, cell in enumerate(cells_list):
cell = cell.strip('"').split('PREVIZ.')[1].replace('.', '-') # "PREVIZ.AAACATACAAGGGC.1" -> AAACATACAAGGGC-1
cells_dict[cell] = i
Expand All @@ -130,7 +132,7 @@ def get_expression_matrix_dict(self):
genes = {}

for line in lines[1:]:
columns = line.strip().split()
columns = line.strip().split(self.infercnv_delimiter)
gene = columns[0].strip('"')
expression_by_cell = list(map(float, columns[1:]))

Expand Down Expand Up @@ -236,6 +238,9 @@ def get_clusters_meta(names, paths):
formatter_class=RawDescriptionHelpFormatter)
ap.add_argument('--infercnv_output',
help='Path to pre_vis_transform.txt output from inferCNV')
ap.add_argument('--infercnv_delimiter',
help='Delimiter in pre_vis_transform.txt output from inferCNV',
default='\t')
ap.add_argument('--gen_pos_file',
help='Path to gen_pos.txt genomic positions file from inferCNV ')
ap.add_argument('--cluster_names',
Expand All @@ -250,11 +255,12 @@ def get_clusters_meta(names, paths):
args = ap.parse_args()

infercnv_output = args.infercnv_output
infercnv_delimiter = args.infercnv_delimiter
gen_pos_file = args.gen_pos_file
cluster_names = args.cluster_names
cluster_paths = args.cluster_paths
output_file = args.output_file

clusters_meta = get_clusters_meta(cluster_names, cluster_paths)

MatrixToIdeogramAnnots(infercnv_output, gen_pos_file, clusters_meta, output_file)
MatrixToIdeogramAnnots(infercnv_output, infercnv_delimiter, gen_pos_file, clusters_meta, output_file)

0 comments on commit 694cd88

Please sign in to comment.