filter_data | R Documentation |
Filtering of spots/cells, genes or samples, as well as count-based filtering
filter_data(
x = NULL,
spot_minreads = 0,
spot_maxreads = NULL,
spot_mingenes = 0,
spot_maxgenes = NULL,
spot_minpct = 0,
spot_maxpct = NULL,
gene_minreads = 0,
gene_maxreads = NULL,
gene_minspots = 0,
gene_maxspots = NULL,
gene_minpct = 0,
gene_maxpct = NULL,
samples = NULL,
rm_tissue = NULL,
rm_spots = NULL,
rm_genes = NULL,
rm_genes_expr = NULL,
spot_pct_expr = "^MT-"
)
x |
an STlist |
spot_minreads |
the minimum number of total reads for a spot to be retained |
spot_maxreads |
the maximum number of total reads for a spot to be retained |
spot_mingenes |
the minimum number of non-zero counts for a spot to be retained |
spot_maxgenes |
the maximum number of non-zero counts for a spot to be retained |
spot_minpct |
the minimum percentage of counts for features defined by |
spot_maxpct |
the maximum percentage of counts for features defined by |
gene_minreads |
the minimum number of total reads for a gene to be retained |
gene_maxreads |
the maximum number of total reads for a gene to be retained |
gene_minspots |
he minimum number of spots with non-zero counts for a gene to be retained |
gene_maxspots |
the maximum number of spots with non-zero counts for a gene to be retained |
gene_minpct |
the minimum percentage of spots with non-zero counts for a gene to be retained |
gene_maxpct |
the maximum percentage of spots with non-zero counts for a gene to be retained |
samples |
samples (as in |
rm_tissue |
sample (as in |
rm_spots |
vector of spot/cell IDs to remove. Removes spots/cells in |
rm_genes |
vector of gene names to remove from STlist. Removes genes in |
rm_genes_expr |
a regular expression that matches genes to remove. Removes genes in |
spot_pct_expr |
a expression to use with |
This function provides options to filter elements in an STlist. It can remove
cells/spots or genes based on raw counts (x@counts
). Users can input an
regular expression to query gene names and calculate percentages (for example %
mtDNA genes). The function also can filter entire samples. Note that the function
removes cells/spots, genes, and/or samples in the raw counts, transformed counts,
spatial variables, gene variables, and sample metadata. Also note that the function
filters in the following order:
Samples (rm_tissue
)
Spots (rm_spots
)
Genes (rm_genes
)
Genes matching rm_genes_expr
Min and max counts
an STlist containing the filtered data
# Using included melanoma example (Thrane et al.)
# Download example data set from spatialGE_Data
thrane_tmp = tempdir()
unlink(thrane_tmp, recursive=TRUE)
dir.create(thrane_tmp)
lk='https://github.com/FridleyLab/spatialGE_Data/raw/refs/heads/main/melanoma_thrane.zip?download='
download.file(lk, destfile=paste0(thrane_tmp, '/', 'melanoma_thrane.zip'), mode='wb')
zip_tmp = list.files(thrane_tmp, pattern='melanoma_thrane.zip$', full.names=TRUE)
unzip(zipfile=zip_tmp, exdir=thrane_tmp)
# Generate the file paths to be passed to the STlist function
count_files <- list.files(paste0(thrane_tmp, '/melanoma_thrane'),
full.names=TRUE, pattern='counts')
coord_files <- list.files(paste0(thrane_tmp, '/melanoma_thrane'),
full.names=TRUE, pattern='mapping')
clin_file <- list.files(paste0(thrane_tmp, '/melanoma_thrane'),
full.names=TRUE, pattern='clinical')
# Create STlist
library('spatialGE')
melanoma <- STlist(rnacounts=count_files[c(1,2)],
spotcoords=coord_files[c(1,2)],
samples=clin_file) # Only first two samples
melanoma <- filter_data(melanoma, spot_minreads=2000)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.