Unverified Commit cb5900ed authored by Yun YAN's avatar Yun YAN Committed by GitHub
Browse files

Merge pull request #13 from Puriney/master

celseq2-to-st understands CSV
parents b62cd1d2 cdbc14c5
......@@ -9,7 +9,7 @@ import argparse
import pandas as pd
def celseq2stpipeline(celseq2_hdf5, spatial_map, out,
def celseq2stpipeline(celseq2_fpath, spatial_map, out,
exclude_empty_spots, exclude_nondetected_genes):
fhout = open(out, 'w')
......@@ -21,8 +21,10 @@ def celseq2stpipeline(celseq2_hdf5, spatial_map, out,
row = row.strip().split()
dict_spatial_seq2xy[row[0]] = (row[1], row[2])
expr = pd.read_hdf(celseq2_hdf5, 'table') # genes x cells
if celseq2_fpath.endswith('h5') or celseq2_fpath.endswith('hdf5'):
expr = pd.read_hdf(celseq2_fpath, 'table') # genes x cells
if celseq2_fpath.endswith('csv'):
expr = pd.read_csv(celseq2_fpath, index_col=0)
# df.loc[(df.sum(axis=1) != 0), (df.sum(axis=0) != 0)]
if (exclude_empty_spots) and (exclude_nondetected_genes):
expr_valid = expr.loc[(expr.sum(axis=1) != 0), (expr.sum(axis=0) != 0)]
......@@ -38,7 +40,8 @@ def celseq2stpipeline(celseq2_hdf5, spatial_map, out,
fhout.write('{}\t{}\n'.format('', '\t'.join(genes))) # header
for colname in colnames:
spot_seq = colname.split('-')[-1]
tmp = colname.replace('.', '-')
spot_seq = tmp.split('-')[-1]
spot_expr = expr_valid[colname].values
spot_xy = dict_spatial_seq2xy.get(spot_seq, None)
if not spot_xy:
......@@ -56,7 +59,7 @@ def celseq2stpipeline(celseq2_hdf5, spatial_map, out,
def main():
parser = argparse.ArgumentParser(add_help=True)
parser.add_argument('celseq2', metavar='FILENAME', type=str,
help=('File path to expr.hdf5 generated by celseq2.'))
help=('File path to expr.hdf5 (expr.h5 or expr.csv) generated by celseq2.'))
parser.add_argument('spatial_map', metavar='FILENAME', type=str,
help='File path to spatial position dictionary.')
parser.add_argument('out', metavar='FILENAME', type=str,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment