reading in data to SPIAT
Closed this issue · 5 comments
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?
Thanks
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
@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?
Yes sorry the argument should be format
. Could you send me your code on formatting the image?
@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:
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.