issue with the stitch-cosmx.jl script
Closed this issue · 1 comments
Hi,
I encountered several issue when trying to run stitch-cosmx.jl.
- I was trying to follow the example,
julia stitch-cosmx.jl /path/to/cosmx-flatfiles transcripts.csv.gz
, to run stitch-cosmx.jl, using
julia stitch-cosmx.jl /mnt/md0/home/huayingqiu/CosMx_pipeline/example_flat_file transcript.csv.gz
However, an error was raised by the glob function in the script because apparently glob in Julia can't start with a /, which is not clear from the example shown in the README.
ERROR: Glob pattern cannot be empty or start with a / character
I am not familiar with Julia so maybe it's a version issue? I am using version 1.10.3. I solved the issue by running the script in the parent folder that contains the flat files folder.
- Another potential issue is that in the julia script, you have
config_filename = glob("$(path)/S0/*/RunSummary/*_ExptConfig.txt")[1]
fov_filename = glob("$(path)/S0/*/RunSummary/latest.fovs.csv")[1]
fov_paths = glob("$(path)/S0/*/AnalysisResults/*/FOV*")
However, for me, the flat file exported doesn't have the S0 folder. I don't know if that's true for everyone but might be good to not hard code the S0 in the pattern.
- In read_fov_positions:
function read_fov_positions(fov_filename::String)
fovs_df = CSV.read(fov_filename, DataFrame, header=false)
rename!(fovs_df, ["slide", "x", "y", "z", "zoffset", "ROI", "FOV"])
fovs = Dict{Int, Tuple{Float64, Float64, Float64}}()
for fov in eachrow(fovs_df)
fovs[fov.FOV] = (fov.x * 1e3, fov.y * 1e3, fov.z * 1e3)
end
return fovs
end
the rename
function specified 7 columns, but in my latest.fovs.csv. There are 8 columns and here is an excerpt:
1, 60.00468903118592, -3.7904828580112597, -0.034128, -2.000, 0, 9, 0
1, 60.00468903118592, -3.2785671623905595, -0.034749, -2.000, 0, 11, 1
1, 59.49277333556522, -3.2785671623905595, -0.034327, -2.000, 0, 12, 2
1, 59.49277333556522, -3.7904828580112597, -0.033709, -2.000, 0, 10, 3
1, 59.72070419474039, -1.835992019274272, -0.036213, -2.000, 0, 29, 4
1, 59.32040921470616, -1.077740951324813, -0.036737, -2.000, 0, 30, 5
1, 60.0247744199587, -0.6120131380157545, -0.037856, -2.000, 0, 32, 6
I believe this resulted in a dimension error:
ERROR: LoadError: DimensionMismatch: Length of nms doesn't match length of x.
Stacktrace:
[1] rename!(x::DataFrames.Index, nms::Vector{Symbol}; makeunique::Bool)
@ DataFrames ~/.julia/packages/DataFrames/58MUJ/src/other/index.jl:55
[2] rename!
@ ~/.julia/packages/DataFrames/58MUJ/src/other/index.jl:44 [inlined]
[3] rename!(df::DataFrame, vals::Vector{String}; makeunique::Bool)
@ DataFrames ~/.julia/packages/DataFrames/58MUJ/src/abstractdataframe/abstractdataframe.jl:209
[4] rename!
@ ~/.julia/packages/DataFrames/58MUJ/src/abstractdataframe/abstractdataframe.jl:207 [inlined]
[5] read_fov_positions(fov_filename::String)
@ Main ~/CosMx_pipeline/stitch-cosmx.jl:73
[6] main()
@ Main ~/CosMx_pipeline/stitch-cosmx.jl:39
[7] top-level scope
@ ~/CosMx_pipeline/stitch-cosmx.jl:101
in expression starting at /mnt/md0/home/huayingqiu/CosMx_pipeline/stitch-cosmx.jl:101
I solved this by adding a random name for the third last column which are all 0s. Maybe some AtoMx update changed the output format? I am completely with you that the CosMX files are shambolic.
Thanks for the report! It seems they changed the file format since the last cosmx dataset I looked at, and of course their file formats are all undocumented 😓
I pushed a fix just now, and I'll release an updated version shortly.