Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Holly Ruess
celseq2
Commits
14393b9f
Commit
14393b9f
authored
Mar 20, 2018
by
yy1533
Browse files
💪
celseq2-to-st supports the csv result of celseq2
parent
66194ddc
Changes
1
Hide whitespace changes
Inline
Side-by-side
celseq2/support/st_pipeline.py
View file @
14393b9f
...
...
@@ -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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment