Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reading in data to SPIAT #30

Closed
cathalgking opened this issue Jan 14, 2024 · 5 comments
Closed

reading in data to SPIAT #30

cathalgking opened this issue Jan 14, 2024 · 5 comments

Comments

@cathalgking
Copy link

Hi. Thanks for your work on the SPIAT package. I have data from a spatial proteomics experiment in the format shown below, which just contains x-y co-ordinates, intensity and mz values.

What function should I use to read this into a SPIAT object? I was trying one of the "format_" functions but did not have any luck. I was also trying to maybe read the data into an SPE object and convert from there to a SPIAT object?

Screenshot 2024-01-15 at 9 55 03 am

Thanks

@fuerzhou
Copy link
Collaborator

fuerzhou commented Mar 5, 2024

Hi @cathalgking,

Thank you for your interest in the tool and I apologise for the delayed response.

SPIAT uses SPE object as the base object to do all operations and calculations of the images. Please try function format_image_to_spe() and use the argument method = "general". Please refer to the tutorial here for guidance.

Yuzhou

@cathalgking
Copy link
Author

@fuerzhou
I just tried this but it does not seem to have the method argument in that function. Did you mean the format argument? When I try format = "general" it gives an Error which is:

Error in data.frame(Cell.ID = Cell_IDs, Phenotype = phenotypes, Cell.X.Position = coord_x,  : 
  arguments imply differing number of rows: 6, 0

Do you know how best to read in this data?

@fuerzhou
Copy link
Collaborator

Yes sorry the argument should be format. Could you send me your code on formatting the image?

@fuerzhou fuerzhou added the question Further information is requested label Mar 20, 2024
@cathalgking
Copy link
Author

@fuerzhou
The code I run is:

spiat <- format_image_to_spe(intensity_matrix = AR_kd_full, format = "general")

And the file I am trying to read in is a data frame which looks like:

Screenshot 2024-03-20 at 2 56 16 pm

@fuerzhou
Copy link
Collaborator

To use this function, you need to follow the instructions in the documentation -

#' @ param format String specifying the format of the data source. Default is
#' "general" (RECOMMENDED), where the cell phenotypes, coordinates and marker
#' intensities are imported manually by the user. Other formats include
#' "inForm", "HALO", "cellprofiler" and "CODEX".
#' @ param intensity_matrix (Optional) For "general" format. A matrix of marker
#' intensities or gene expression where the column names are the Cell IDs, and
#' the rownames the marker.
#' @ param phenotypes (Optional) For "general" format. String Vector of cell
#' phenotypes in the same order in which they appear in intensity_matrix. If
#' no phenotypes available, then a vector of NAs can be used as input. Note
#' that the combination of markers (e.g. CD3,CD4) needs to be used instead of
#' the cell type name (e.g. helper T cells).
#' @ param coord_x (Optional) For "general" format. Numeric Vector with the X
#' coordinates of the cells. The cells must be in the same order as in the
#' intensity_matrix.
#' @ param coord_y (Optional) For "general" format. Numeric Vector with the Y
#' coordinates of the cells. The cells must be in the same order as in the
#' intensity_matrix.

It seems that you put the x,y coordinates, intensities all in the same data frame. Instead, you need to specify each argument separately.

@fuerzhou fuerzhou removed the question Further information is requested label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants