Read in detected transcripts file/s into a MoleculeExperiment object
Source:R/readMolecules.R
readMolecules.Rd
A function to standardise transcripts.csv files across different molecule- based ST technologies, and store them into an ME object. It is technology agnostic, so it is accompanied with wrappers for the specific technologies (e.g., see readXenium).
Usage
readMolecules(
dataDir,
pattern = NULL,
featureCol = NULL,
xCol = NULL,
yCol = NULL,
keepCols = "essential",
moleculesAssay = NULL,
scaleFactorVector = 1
)
Arguments
- dataDir
Character string specifying the directory with the file/s containing detected transcripts for different runs/samples.
- pattern
Character string specifying the pattern with which to find the transcripts files. For example, in Xenium data, the pattern would be "transcripts.csv". In contrast, in Cosmx data, the pattern would be "tx_file".
- featureCol
Character string specifying the name of the column with feature names. For example, "feature_name" in xenium transcripts.csv files.
- xCol
Character string specifying the name of the column with the x locations of the transcripts.
- yCol
Character string specifying the name of the column with the y locations of the transcripts.
- keepCols
Vector of characters specifying the columns of interest from the transcripts file. "essential" selects columns with gene names, x and y locations. "all" will select all columns. Alternatively, specific colums of interest can be selected by specifying them as characters in a vector. Note that this personalised vector needs to contain the essential columns.
- moleculesAssay
Character string specifying the name of the list in which the transcript information is going to be stored in the molecules slot. The default name is "detected", as we envision that a MoleculeExperiment will usually be created with raw detected transcript information.
- 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.
Examples
repoDir <- system.file("extdata", package = "MoleculeExperiment")
repoDir <- paste0(repoDir, "/xenium_V1_FF_Mouse_Brain")
simple_me <- readMolecules(repoDir,
pattern = "transcripts.csv",
featureCol = "feature_name",
xCol = "x_location",
yCol = "y_location",
keepCols = "essential"
)
simple_me
#> MoleculeExperiment class
#>
#> molecules slot (1): detected
#> - detected:
#> samples (2): sample1 sample2
#> -- sample1:
#> ---- features (137): 2010300C02Rik Acsbg1 ... Zfp536 Zfpm2
#> ---- molecules (962)
#> ---- location range: [4900,4919.98] x [6400.02,6420]
#> -- sample2:
#> ---- features (143): 2010300C02Rik Acsbg1 ... Zfp536 Zfpm2
#> ---- molecules (777)
#> ---- location range: [4900.01,4919.98] x [6400.16,6419.97]
#>
#>
#> boundaries slot: NULL