knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
library(Giotto)
## visual cortex expression DATA ## VC_exprs = read.table(system.file("extdata", "cortex_svz_expression.txt", package = "Giotto")) ## prepare cell locations VC_locs = fread(system.file("extdata", "cortex_svz_centroids_rotated.csv", package = "Giotto")) my_offset_file = data.table(field = c(0, 1, 2, 3, 4, 5, 6), x_offset = c(0, 2048, 2048, 2048, 675, 2048, 675), y_offset = c(2048, 2048, 2048, 2048,0, 0, 2048)) stitch_file = stitchFieldCoordinates(location_file = VC_locs, offset_file = my_offset_file, cumulate_offset_x = T, cumulate_offset_y = F, field_col = 'Field of View', reverse_final_x = F, reverse_final_y = T) stitch_file = stitch_file[,.(X_final, Y_final)] my_offset_file = my_offset_file[,.(field, x_offset_final, y_offset_final)]
## create VC_test <- createGiottoObject(raw_exprs = VC_exprs, spatial_locs = stitch_file, offset_file = my_offset_file) ## filter VC_test <- filterGiotto(gobject = VC_test, expression_threshold = 1, min_det_genes_per_cell = 10, gene_det_in_min_cells = 10, expression_values = c('raw')) ## normalize VC_test <- normalizeGiotto(gobject = VC_test) # gene and cell statistics VC_test <- addStatistics(gobject = VC_test) # adjust for covariates VC_test = adjustGiottoMatrix(gobject = VC_test, expression_values = c('normalized'), batch_columns = NULL, covariate_columns = c('nr_genes', 'total_expr'), return_gobject = TRUE, update_slot = c('custom'))
Start from Giotto object from the Mouse Visual Cortex and SVZ:
spatPlot(gobject = VC_test, point_size = 2, return_plot = F)
# cell metadata before print(pDataDT(VC_test)) # add metadata by column name cortex_annotation = fread(system.file("extdata", "cortex_annotation.txt", package = "Giotto")) VC_test = addCellMetadata(gobject = VC_test, new_metadata = cortex_annotation, by_column = T, column_cell_ID = 'uniq_ID') # cell metadata after cell_metadata = pDataDT(VC_test) print(cell_metadata)
first_500_cells = cell_metadata[1:500][['cell_ID']] VC_subset = subsetGiotto(VC_test, cell_ids = first_500_cells) spatPlot2D(gobject = VC_subset, point_size = 2, cell_color = 'cell_types', return_plot = F)
SVZ_cells = cell_metadata[Field_of_View == 5][['cell_ID']] VC_SVZ = subsetGiotto(VC_test, cell_ids = SVZ_cells) spatPlot2D(gobject = VC_SVZ, point_size = 4, cell_color = 'cell_types', return_plot = F)
interneuron_cells = cell_metadata[cell_types == 'Interneuron'][['cell_ID']] VC_interneuron = subsetGiotto(VC_test, cell_ids = interneuron_cells) spatPlot2D(gobject = VC_interneuron, point_size = 2, cell_color = 'cell_types', return_plot = F)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.