sub_data {spatialHeatmap} | R Documentation |
This function subsets the target spatial features (e.g. cells, tissues, organs) and factors (e.g. experimental treatments, time points) for the subsequent spatial enrichment.
sub_data( data, feature, features = NULL, factor, factors = NULL, com.by = "feature", target = NULL )
data |
A |
feature |
The column name of "features" in the |
features |
A vector of at least two selected features for spatial enrichment, which come from the |
factor |
The column name of "factors" in the |
factors |
A vector of at least two selected factors for spatial enrichment, which come from the |
com.by |
One of |
target |
A single-component vector of the target for spatial enrichment. If |
A subsetted SummarizedExperiment
object.
Jianhai Zhang jzhan067@ucr.edu; zhang.jianhai@hotmail.com
Dr. Thomas Girke thomas.girke@ucr.edu
Cardoso-Moreira, Margarida, Jean Halbert, Delphine Valloton, Britta Velten, Chunyan Chen, Yi Shao, Angélica Liechti, et al. 2019. “Gene Expression Across Mammalian Organ Development.” Nature 571 (7766): 505–9
Keays, Maria. 2019. ExpressionAtlas: Download Datasets from EMBL-EBI Expression Atlas
Martin Morgan, Valerie Obenchain, Jim Hester and Hervé Pagès (2018). SummarizedExperiment: SummarizedExperiment container. R package version 1.10.1
## In the following examples, the toy data come from an RNA-seq analysis on development of 7 ## chicken organs under 9 time points (Cardoso-Moreira et al. 2019). For conveninece, it is ## included in this package. The complete raw count data are downloaded using the R package ## ExpressionAtlas (Keays 2019) with the accession number "E-MTAB-6769". ## Set up toy data. # Access toy data. cnt.chk <- system.file('extdata/shinyApp/example/count_chicken.txt', package='spatialHeatmap') count.chk <- read.table(cnt.chk, header=TRUE, row.names=1, sep='\t') count.chk[1:3, 1:5] # A targets file describing samples and conditions is required for toy data. It should be made # based on the experiment design, which is accessible through the accession number # "E-MTAB-6769" in the R package ExpressionAtlas. An example targets file is included in this # package and accessed below. # Access the count table. cnt.chk <- system.file('extdata/shinyApp/example/count_chicken.txt', package='spatialHeatmap') count.chk <- read.table(cnt.chk, header=TRUE, row.names=1, sep='\t') count.chk[1:3, 1:5] # Access the example targets file. tar.chk <- system.file('extdata/shinyApp/example/target_chicken.txt', package='spatialHeatmap') target.chk <- read.table(tar.chk, header=TRUE, row.names=1, sep='\t') # Every column in toy data corresponds with a row in targets file. target.chk[1:5, ] # Store toy data in "SummarizedExperiment". library(SummarizedExperiment) se.chk <- SummarizedExperiment(assay=count.chk, colData=target.chk) # The "rowData" slot can store a data frame of gene metadata, but not required. Only the # column named "metadata" will be recognized. # Pseudo row metadata. metadata <- paste0('meta', seq_len(nrow(count.chk))); metadata[1:3] rowData(se.chk) <- DataFrame(metadata=metadata) ## As conventions, raw sequencing count data should be normalized and filtered to ## reduce noise. Since normalization will be performed in spatial enrichment, only filtering ## is required before subsetting the data. # Filter out genes with low counts and low variance. Genes with counts over 5 in # at least 10% samples (pOA), and coefficient of variance (CV) between 3.5 and 100 are # retained. se.fil.chk <- filter_data(data=se.chk, sam.factor='organism_part', con.factor='age', pOA=c(0.1, 5), CV=c(3.5, 100), dir=NULL) # Subset the data. data.sub <- sub_data(data=se.fil.chk, feature='organism_part', features=c('brain', 'heart', 'kidney'), factor='age', factors=c('day10', 'day12'), com.by='feature', target='brain')