Read in csv boundary information and convert to ME list format.
Source:R/readBoundaries.R
readBoundaries.Rd
This function reads in csv boundary files and converts them to the ME list format, so that they can be added to an ME object later on. To account for different coordinate scales possible being used by the boundary versus transcript information, this function scales the coordinate values of the boundaries to match the unit of the detected transcript locations. The various arguments offer flexibility to standardise data from different molecule-based ST technologies into the ME list format.
Usage
readBoundaries(
dataDir,
pattern = NULL,
segmentIDCol = NULL,
xCol = NULL,
yCol = NULL,
keepCols = "essential",
boundariesAssay = NULL,
scaleFactorVector = 1
)
Arguments
- dataDir
Path of the directory containing the boundary csv files.
- pattern
Character string specifying the unique pattern with which to identify the files of interest in the directory. This is useful to work with multiple samples. Defaults to NULL.
- segmentIDCol
Character string specifying the name of the column containing the segment IDs. Defaults to NULL.
- xCol
Character string specifying the name of the column containing the x coordinates of the vertices defining the boundaries. Defaults to NULL.
- yCol
Character string specifying the name of the column containing the y coordinates of the vertices defining the boundaries. Defaults to NULL.
- keepCols
Character string specifying which columns to keep. Defaults to "essential". The other option is to select "all", or custom columns by specifying their names in a vector.
- boundariesAssay
Character string specifying the name with which to identify the boundary data in the ME object later on. Defaults to NULL.
- scaleFactorVector
Vector containing the scale factor/s with which to change the coordinate data from pixel to micron. It can be either a single integer, or multiple scale factors for the different samples. The default value is 1.
Value
An ME list containing the boundary information. This can be used as input to the boundaries slot of an ME object.
Examples
repoDir <- system.file("extdata", package = "MoleculeExperiment")
repoDir <- paste0(repoDir, "/xenium_V1_FF_Mouse_Brain")
nucleiMEList <- readBoundaries(dataDir = repoDir,
pattern = "nucleus_boundaries.csv",
segmentIDCol = "cell_id",
xCol = "vertex_x",
yCol = "vertex_y",
keepCols = "essential",
boundariesAssay = "nucleus",
scaleFactorVector = 1)
nucleiMEList
#> $nucleus
#> $nucleus$sample1
#> $nucleus$sample1$`67500`
#> # A tibble: 13 × 2
#> x_location y_location
#> <dbl> <dbl>
#> 1 4900. 6407.
#> 2 4898. 6409.
#> 3 4897. 6411.
#> 4 4898. 6414.
#> 5 4899. 6416.
#> 6 4900. 6416.
#> 7 4902. 6416.
#> 8 4905. 6414.
#> 9 4906. 6413.
#> 10 4905. 6410.
#> 11 4904. 6408.
#> 12 4902. 6407.
#> 13 4900. 6407.
#>
#> $nucleus$sample1$`67512`
#> # A tibble: 13 × 2
#> x_location y_location
#> <dbl> <dbl>
#> 1 4909. 6407.
#> 2 4907. 6409.
#> 3 4907. 6411.
#> 4 4908. 6413.
#> 5 4910. 6414.
#> 6 4913. 6414.
#> 7 4913. 6413.
#> 8 4914. 6413.
#> 9 4914. 6412.
#> 10 4912. 6410.
#> 11 4911. 6408.
#> 12 4909. 6407.
#> 13 4909. 6407.
#>
#> $nucleus$sample1$`67515`
#> # A tibble: 13 × 2
#> x_location y_location
#> <dbl> <dbl>
#> 1 4912. 6405.
#> 2 4910. 6405.
#> 3 4909. 6407.
#> 4 4913. 6409.
#> 5 4913. 6411.
#> 6 4914. 6412.
#> 7 4915. 6412.
#> 8 4915. 6411.
#> 9 4917. 6409
#> 10 4917. 6408.
#> 11 4915. 6406.
#> 12 4913. 6405.
#> 13 4912. 6405.
#>
#> $nucleus$sample1$`67521`
#> # A tibble: 13 × 2
#> x_location y_location
#> <dbl> <dbl>
#> 1 4918. 6411.
#> 2 4917. 6411.
#> 3 4916. 6412.
#> 4 4914. 6415.
#> 5 4914. 6417.
#> 6 4916. 6419.
#> 7 4917. 6418.
#> 8 4918. 6417.
#> 9 4920. 6414.
#> 10 4920. 6412.
#> 11 4919. 6411.
#> 12 4918. 6411.
#> 13 4918. 6411.
#>
#> $nucleus$sample1$`67527`
#> # A tibble: 13 × 2
#> x_location y_location
#> <dbl> <dbl>
#> 1 4921. 6411.
#> 2 4920. 6412.
#> 3 4920. 6415.
#> 4 4919. 6418.
#> 5 4919. 6418.
#> 6 4921. 6418.
#> 7 4922. 6419.
#> 8 4923. 6419.
#> 9 4924. 6418.
#> 10 4924. 6416.
#> 11 4923. 6412.
#> 12 4922. 6411.
#> 13 4921. 6411.
#>
#>
#> $nucleus$sample2
#> $nucleus$sample2$`65044`
#> # A tibble: 13 × 2
#> x_location y_location
#> <dbl> <dbl>
#> 1 4904. 6418.
#> 2 4902. 6420.
#> 3 4902. 6421.
#> 4 4902. 6423.
#> 5 4902. 6425.
#> 6 4903. 6426.
#> 7 4906. 6425.
#> 8 4908. 6424.
#> 9 4908. 6423.
#> 10 4908. 6422.
#> 11 4907. 6420.
#> 12 4905. 6418.
#> 13 4904. 6418.
#>
#> $nucleus$sample2$`65051`
#> # A tibble: 13 × 2
#> x_location y_location
#> <dbl> <dbl>
#> 1 4919. 6416.
#> 2 4917. 6417.
#> 3 4915. 6423.
#> 4 4915. 6426.
#> 5 4916. 6427.
#> 6 4917. 6428.
#> 7 4919. 6429.
#> 8 4920. 6429.
#> 9 4922. 6428.
#> 10 4924. 6422.
#> 11 4923. 6418.
#> 12 4920. 6416.
#> 13 4919. 6416.
#>
#> $nucleus$sample2$`65055`
#> # A tibble: 13 × 2
#> x_location y_location
#> <dbl> <dbl>
#> 1 4909. 6408.
#> 2 4907. 6408.
#> 3 4904. 6410.
#> 4 4902. 6413.
#> 5 4903. 6415.
#> 6 4906. 6417.
#> 7 4906. 6417.
#> 8 4910. 6417.
#> 9 4911. 6416.
#> 10 4912. 6414.
#> 11 4912. 6410.
#> 12 4910. 6408.
#> 13 4909. 6408.
#>
#> $nucleus$sample2$`65063`
#> # A tibble: 13 × 2
#> x_location y_location
#> <dbl> <dbl>
#> 1 4923. 6412.
#> 2 4922. 6413.
#> 3 4921. 6413.
#> 4 4920. 6415.
#> 5 4920. 6415.
#> 6 4922. 6417.
#> 7 4924. 6416.
#> 8 4925. 6416.
#> 9 4927. 6415.
#> 10 4927. 6414.
#> 11 4927. 6413.
#> 12 4926. 6412.
#> 13 4923. 6412.
#>
#> $nucleus$sample2$`65064`
#> # A tibble: 13 × 2
#> x_location y_location
#> <dbl> <dbl>
#> 1 4898. 6403.
#> 2 4896. 6404.
#> 3 4894. 6409.
#> 4 4894. 6410.
#> 5 4895. 6411.
#> 6 4896. 6412.
#> 7 4898. 6412.
#> 8 4899. 6411.
#> 9 4900. 6409.
#> 10 4901. 6407.
#> 11 4901. 6403.
#> 12 4899. 6403.
#> 13 4898. 6403.
#>
#>
#>