read_cpout {imcRtools} | R Documentation

## Reads in single-cell data generated by the ImcSegmentationPipeline

### Description

Reader function to generate a `SpatialExperiment` or `SingleCellExperiment` object from single-cell data obtained by the ImcSegmentationPipeline pipeline.

### Usage

    read_cpout(
      path,
      object_file = "cell.csv",
      image_file = "Image.csv",
      panel_file = "panel.csv",
      graph_file = "Object relationships.csv",
      object_feature_file = "var_cell.csv",
      intensities = "Intensity_MeanIntensity_FullStackFiltered",
      extract_imgid_from = "ImageNumber",
      extract_cellid_from = "ObjectNumber",
      extract_coords_from = c("Location_Center_X", "Location_Center_Y"),
      extract_cellmetadata_from = "Neighbors_NumberOfNeighbors_8",
      extract_imagemetadata_from = c("Metadata_acname", "Metadata_acid",
        "Metadata_description"),
      extract_graphimageid_from = "First Image Number",
      extract_graphcellids_from = c("First Object Number", "Second Object Number"),
      extract_metal_from = "Metal Tag",
      scale_intensities = TRUE,
      extract_scalingfactor_from = "Scaling_FullStack",
      return_as = c("spe", "sce")
    )

### Arguments

`path` | full path to the CellProfiler output folder.
`object_file` | single character indicating the file name storing the object/cell-specific intensities and metadata.
`image_file` | single character indicating the file name storing meta data per image (can be `NULL`).
`panel_file` | single character indicating the file name storing the panel information (can be `NULL`).
`graph_file` | single character indicating the file name storing the object/cell interaction information (can be `NULL`).
`object_feature_file` | single character indicating the file name storing object/cell feature information.
`intensities` | single character indicating which column entries of the `object_file` contain the intensity features of interest. See details.
`extract_imgid_from` | single character indicating which column entries of the `object_file` and `image_file` contain the image integer ID.
`extract_cellid_from` | single character indicating which column entry of the `object_file` contains the object/cell integer ID.
`extract_coords_from` | character vector indicating which column entries of the `object_file` contain the x and y location of the objects/cells.
`extract_cellmetadata_from` | character vector indicating which additional object/cell specific metadata to extract from the `object_file`.
`extract_imagemetadata_from` | character vector indicating which additional image specific metadata to extract from the `image_file`. These will be stored in the `colData(x)` slot as object/cell-specific entries.
`extract_graphimageid_from` | single character indicating which column entries of the `graph_file` contain the image integer ID.
`extract_graphcellids_from` | character vector indicating which column entries of the `graph_file` contain the first and second object/cell integer IDs. These will be stored as the `from` and `to` entry of the `SelfHits` object in colPair(x, "neighborhood").
`extract_metal_from` | single character indicating which column entry of the `panel_file` contains the metal isotopes of the used antibodies. This entry is used to match the panel information to the acquired channel information.
`scale_intensities` | single logical. Should the measured intensity features be scaled by `extract_scalingfactor_from`.
`extract_scalingfactor_from` | single character indicating which column entries of the `image_file` contain the image specific scaling factor.
`return_as` | should the object be returned as `SpatialExperiment` (`return_as = "spe"`) or `SingleCellExperiment` (`return_as = "sce"`).

### Value

returns a `SpatialExperiment` or `SingleCellExperiment` object with markers in rows and cells in columns.

### The returned data container

In the case of both containers `x`, intensity features (as selected by the `intensities` parameter) are stored in the `counts(x)` slot. Cell metadata (e.g morphological features) are stored in the `colData(x)` slot. The interaction graphs are stored as `SelfHits` object in the `colPair(x, "neighborhood")` slot.

Intensity features are extracted via partial string matching. Internally, the `read_cpout` function checks if per channel a single intensity feature is read in (by checking the `_cXY` ending where `XY` is the channel number).

In the case of a returned `SpatialExperiment` object, the cell coordinates are stored in the `spatialCoords(x)` slot.

In the case of a returned `SingleCellExperiment` object, the cell coordinates are stored in the `colData(x)` slot named as `Pos_X` and `Pos_Y`.

### Author(s)

Tobias Hoch

Nils Eling (nils.eling@dqbm.uzh.ch)

### See Also

https://github.com/BodenmillerGroup/ImcSegmentationPipeline for the pipeline

`read_steinbock` for reading in single-cell data as produced by the steinbock pipeline

`colPair` for information on how to work with the cell-cell interaction graphs

### Examples

    path <- system.file("extdata/mockData/cpout", package = "imcRtools")

    # Read in as SpatialExperiment object
    x <- read_cpout(path, graph_file = "Object_relationships.csv")
    x

    # Read in as SingleCellExperiment object
    x <- read_cpout(path, graph_file = "Object_relationships.csv",
                    return_as = "sce")
    x

[Package imcRtools version 1.0.2 Index]