Open YuxiZhang-0113 opened 1 month ago
Hi
I tried subset_fov
and it works fine with VisiumHD. I can not locate the .=>> bug you mentioned in the source code of the package. Can you point me to the line in this repo?
Hi,
I encountered an issue when running the following code:
df = cs.subset_fov(hd, [193, 197, 333, 337], 20, 20)
This results in an UndefVarError stating "x_col not defined":
Stacktrace: [1] subset_fov(sp::CellScopes.VisiumHDObject, fov::Vector{Int64}, n_fields_x::Int64, n_fields_y::Int64) @ CellScopes ~/.julia/packages/CellScopes/pM38e/src/spatial/sp_utils.jl:241 [2] top-level scope @ In[5]:1
Attempting to dive deeper into the source with @edit cs.subset_fov(hd, [193,197,333,337], 20,20) yielded the following relevant part of the code:
if isa(sp, VisiumObject) df = deepcopy(sp.spmetaData) rename!(df, [:barcode, :pxl_row_in_fullres, :pxl_col_in_fullres] .=> [:cell, :x, :y]) elseif isa(sp, VisiumHDObject) if isa(sp.alterImgData, Nothing) df = deepcopy(sp.spmetaData) rename!(df, [:barcode, :pxl_row_in_fullres, :pxl_col_in_fullres] .=>> [:cell, Symbol(x_col), Symbol(y_col)]) else df = deepcopy(sp.alterImgData.posData.positions["high_pos"]) end else df = deepcopy(sp.spmetaData.cell) end
As a newcomer to Julia, I am unsure if this is a simple syntax error or if there is another underlying issue. I have had no problems when running similar functions with Cartana and Visium data.
Thank you very much for your support!
Best regards
I still do not see the .=>>
in my source code. Here is what I have in this repo for the subset_fov function.
function subset_fov(sp::get_object_group("Spatial"), fov::Vector{Int64}, n_fields_x::Int64, n_fields_y::Int64)
if isa(sp, VisiumObject)
df = deepcopy(sp.spmetaData)
rename!(df, [:barcode, :pxl_row_in_fullres, :pxl_col_in_fullres] .=> [:cell, :x, :y])
elseif isa(sp, VisiumHDObject)
if isa(sp.alterImgData, Nothing)
df = deepcopy(sp.spmetaData)
rename!(df, [:barcode, :pxl_row_in_fullres, :pxl_col_in_fullres] .=> [:cell, Symbol(x_col), Symbol(y_col)])
else
df = deepcopy(sp.alterImgData.posData.positions["high_pos"])
end
else
df = deepcopy(sp.spmetaData.cell)
end
pts, centroids = split_field(df, n_fields_x, n_fields_y)
pts_sub=pts[fov]
min_pt=minimum(minimum(pts_sub))
max_pt=maximum(maximum(pts_sub))
min_pt=convert(Vector{Float32}, min_pt)
max_pt=convert(Vector{Float32}, max_pt)
df_sub=filter([:x, :y] => (x, y) -> x > min_pt[1] && x < max_pt[1] && y > min_pt[2] && y < max_pt[2], df)
return df_sub
end
You can reinstall the package and see if the issue goes away.
Hi, thank you very much for your response. I have updated the version of CellScopes, and I found the sp_utils.jl file. This part indeed does not have an issue with .=>>. However, when running cs.subset_fov with VisiumHDObject, I still encounter an error:
ERROR: UndefVarError: x_col not defined Stacktrace: [1] subset_fov(sp::CellScopes.VisiumHDObject, fov::Vector{Int64}, n_fields_x::Int64, n_fields_y::Int64) @ CellScopes ~/.julia/packages/CellScopes/zSJaP/src/spatial/sp_utils.jl:241 [2] top-level scope @ REPL[6]:1
I am running the original function, where sp is a VisiumHDObject. In this part:
elseif isa(sp, VisiumHDObject)
if isa(sp.alterImgData, Nothing)
df = deepcopy(sp.spmetaData)
x_col = "pxl_col_in_fullres"
y_col = "pxl_row_in_fullres"
rename!(df, [:barcode, :pxl_row_in_fullres, :pxl_col_in_fullres] .=> [:cell, Symbol(x_col), Symbol(y_col)])
else
df = deepcopy(sp.alterImgData.posData.positions["high_pos"])
end
I receive the following error: x_col not defined.
I see the bug now. I have fixed it. Thanks for reporting.
I greatly appreciate the time and effort you've dedicated to addressing my previous issues—your detailed responses have been incredibly helpful. Thank you for your patience and support.
I apologize for the inconvenience, but I have a few more questions:
cs.subset_fov
function works well with Xenium objects, however, I receive an error when using cs.plot_fov:
cs.plot_fov(xenium, 20, 10)
UndefRefError: access to undefined reference
Stacktrace: [1] getproperty @ ./Base.jl:42 [inlined] [2] (::CellScopes.var"#346#348")(sp::CellScopes.XeniumObject; adjust_coord_to_img::String, x_col::String, y_col::String) @ CellScopes ~/.julia/packages/CellScopes/zSJaP/src/spatial/sp_utils.jl:820 [3] plot_fov(sp::CellScopes.XeniumObject, n_fields_x::Int64, n_fields_y::Int64; x_col::String, y_col::String, group_label::Nothing, alpha::Int64, adjust_coord_to_img::String, custom_img::Bool, width::Int64, height::Int64, cell_highlight::Nothing, shield::Bool, marker_size::Nothing) @ CellScopes ~/.julia/packages/CellScopes/zSJaP/src/spatial/sp_plots.jl:1012 [4] plot_fov(sp::CellScopes.XeniumObject, n_fields_x::Int64, n_fields_y::Int64) @ CellScopes ~/.julia/packages/CellScopes/zSJaP/src/spatial/sp_plots.jl:981 [5] top-level scope @ In[7]:1
Now that you have fixed the part for VisiumHD, do I need to reinstall CellScopes right now?
Regarding some Xenium data, the 10X official site generally provides OME-tiff files. I have tried converting them using Matlab, and also tried converting directly to TIFF files using ImageJ. So far, the data I obtained can be added to XeniumObject using add_xenium_img, but I cannot produce any plots. I may need to try a few more times; however, do you have any recommendations for TIFF file conversion? Below is my Matlab code:
ome_tiff = imread('ome.tiff');
imwrite(ome_tiff, 'standard.tiff');
I appreciate any advice you can provide. Thank you in advance.
Hi,
1. I encountered an error while testing the Xenium data. The cs.subset_fov function works well with Xenium objects, however, I receive an error when using cs.plot_fov:
This should be fixed now. Now plot_fov
supports XeniumObject without imaging data.
2. Now that you have fixed the part for VisiumHD, do I need to reinstall CellScopes right now? Yes, please reinstall it and let me know if you come across other issues. I may be slow to fix it but will definitely work on it whenever i get a chance.
3. Regarding some Xenium data, the 10X official site generally provides OME-tiff files... Not sure about using matlab script. I usually use software to do it such as Fiji and QuPath.
Hope this helps and thanks for reporting bugs!
Hi! Thank you for your help. I've been busy lately, hence the delayed response.
I have tested the plot_fov and subset_fov functions, and they work perfectly with Xenium objects, VisiumHD, and Visium objects.
I have encountered another issue. I followed the tutorial to incorporate breast cancer H&E image data into a Xenium object, but I noticed that the Dimplot and HE images don't seem to align perfectly. It appears that the Dimplot is slightly misaligned, as shown in the image below:
Also, I am unsure if this is due to an installation issue:
using Pkg
Pkg.add(url="https://github.com/HaojiaWu/CellScopes.jl")
Pkg.status()
Status
~/.julia/environments/v1.7/Project.toml
[336ed68f] CSV v0.10.14 [13f3f980] CairoMakie v0.12.3 [708d50d9] CellScopes v0.1.0https://github.com/HaojiaWu/CellScopes.jl#main
I just installed it today, but it still shows version 0.1.0 for some reason.
I appreciate your assistance in resolving these issues. Thank you again for your support.
Dear CellScopes Team,
I encountered an error while running the subset_fov function for VisiumHD data using the following code:
df = cs.subset_fov(hd, [89,109], 26, 20)
Here is the error message I received:
While reviewing the function definition, I noticed the following line:
rename!(df, [:barcode, :pxl_row_in_fullres, :pxl_col_in_fullres] .=>> [:cell, Symbol(x_col), Symbol(y_col)])
I was wondering if perhaps the .=>> should be replaced with .=>. I am not entirely sure if this change is appropriate. This function has worked excellently with other Visium data sets, and this issue seems to be specific to VisiumHD.
Any guidance or clarification you could provide would be greatly appreciated.