# pixelatorR pixelatorR provides the infrastructure to process, analyze and visualize MPX and Proximity Network Assay (PNA) data for R users. ![Pixelgen Technologies](https://www.pixelgen.com/wp-content/uploads/2022/12/share-image-pixelgen.png) © 2023 - Pixelgen Technologies AB ## Installation pixelatorR can be installed from GitHub by running the following code from R: ``` r install.packages("remotes") remotes::install_github("PixelgenTechnologies/pixelatorR") ``` ### Installation from source You can also install pixelatorR from source by cloning the repository. ``` console git clone https://github.com/pixelgentechnologies/pixelatorR.git ``` Then, in an R session, run: ``` r install.packages("", repos = NULL, type = "source") ``` ## Usage Visit our [tutorials](https://software.pixelgen.com/mpx-analysis/introduction) for a step-by step guide on MPX/PNA data analysis with pixelatorR. On this site, we also provide additional additional tutorials that are more directed towards users who are interested in the details of how pixelatorR stores and handles MPX/PNA data in R. Function documentation can be accessed from the [reference](https://pixelgentechnologies.github.io/pixelatorR/reference/) tab above. Alternatively, you can access the documentation from an R session by running `?function_name` in the console once the package is installed. ## Notes pixelatorR is designed to work with classes from the [SeuratObject](https://github.com/satijalab/seurat-object) R package. For the best analysis experience, we recommend installing [Seurat v5](https://satijalab.org/seurat/). ## Contact For feature requests or bug reports, please use the GitHub [issues](https://github.com/PixelgenTechnologies/pixelatorR/issues). You can also email the development team at . ## Credits pixelatorR is developed and maintained by the [developers](https://github.com/PixelgenTechnologies) at [Pixelgen Technologies](https://pixelgen.com). When using pixelatorR in your research, please cite the following publication: > Karlsson, F., Kallas, T., Thiagarajan, D. et al. Molecular pixelation: > spatial proteomics of single cells by sequencing. Nat Methods 21, > 1044–1052 (2024). . Package maintainer: - Ludvig Larsson ([@ludvigla](https://github.com/ludvigla)) Contributors: - Max Karlsson ([@maxkarlsson](https://github.com/maxkarlsson)) - Vincent Van Hoef ([@vincent-van-hoef](https://github.com/vincent-van-hoef)) - Stefan Petkov ([@stefanppetkov](https://github.com/stefanppetkov)) A huge thank you to all [code contributors](https://github.com/PixelgenTechnologies/pixelatorR/graphs/contributors)! # Package index ## Function reference ### Load data - [`ReadMPX_Seurat()`](ReadMPX_Seurat.md) : Load data from PXL file into a `Seurat` object - [`ReadMPX_counts()`](ReadMPX_counts.md) : Read a count matrix from a pxl file - [`ReadMPX_item()`](ReadMPX_item.md) [`ReadMPX_polarization()`](ReadMPX_item.md) [`ReadMPX_colocalization()`](ReadMPX_item.md) [`ReadMPX_edgelist()`](ReadMPX_item.md) : Read an MPX data item - [`ReadMPX_arrow_edgelist()`](ReadMPX_arrow_edgelist.md) : Read edgelists from a PXL file containing MPX data - [`ReadMPX_layouts()`](ReadMPX_layouts.md) : Load layouts from an PXL file containing MPX data - [`ReadMPX_metadata()`](ReadMPX_metadata.md) : Read metadata from a PXL file - [`ReadPNA_Seurat()`](ReadPNA_Seurat.md) : Load data from PNA PXL file into a `Seurat` object - [`ReadPNA_counts()`](ReadPNA_counts.md) : Read a count matrix from a PXL file with PNA data - [`ReadPNA_edgelist()`](ReadPNA_edgelist.md) : Load the edge list from a PNA PXL file - [`ReadPNA_proximity()`](ReadPNA_proximity.md) : Load the Proximity scores table from a PNA PXL file - [`ReadPNA_layouts()`](ReadPNA_layouts.md) : Load layouts from a PNA PXL file - [`ReadPNA_metadata()`](ReadPNA_metadata.md) : Read metadata from a PNA PXL file - [`read_pbmc_reference()`](read_pbmc_reference.md) : Read PBMC cell annotation reference ### PXL file database - [`PixelDB`](PixelDB.md) : PXL database class - [`get_duckdb_config()`](get_duckdb_config.md) : Fetches the config values to be used with DuckDB ### Visualization - [`CellCountPlot()`](CellCountPlot.md) : Plot cell counts per group - [`MoleculeRankPlot()`](MoleculeRankPlot.md) : Molecule Rank Plot - [`EdgeRankPlot()`](EdgeRankPlot.md) **\[deprecated\]** : Edge Rank Plot - [`TauPlot()`](TauPlot.md) : Plot UMIs per UPIa for quality control - [`DensityScatterPlot()`](DensityScatterPlot.md) : Create a density scatter / pseudocolor plot. - [`AbundanceColocalizationPlot()`](AbundanceColocalizationPlot.md) **\[deprecated\]** : Create an abundance/colocalization scatterplot - [`Plot2DGraph()`](Plot2DGraph.md) **\[deprecated\]** : Plot 2D graph layouts - [`Plot2DGraphM()`](Plot2DGraphM.md) **\[deprecated\]** : Plot multiple markers on multiple graphs - [`Plot3DGraph()`](Plot3DGraph.md) **\[deprecated\]** : Plot 3D graph layouts ### Cell plots - [`cell_plot()`](cell_plot.md) : Create a cell plot recipe - [`build_cell_plot()`](build_cell_plot.md) : Build a cell plot recipe - [`autoplot(`*``*`)`](autoplot.cell_plot.md) : Create a complete ggplot from a `cell_plot` recipe - [`print(`*``*`)`](print.cell_plot.md) : Print a cell plot recipe - [`summary(`*``*`)`](summary.cell_plot.md) : Summarise a cell plot recipe - [`print(`*``*`)`](print.summary.cell_plot.md) : Print a cell plot summary - [`cell_grid()`](cell_grid.md) : Arrange a cell plot in a panel grid - [`cell_node_scale_color()`](cell_node_scale_color.md) : Set the cell plot node color scale - [`cell_node_scale_size()`](cell_node_scale_size.md) : Set the cell plot node size scale - [`cell_node_scale_alpha()`](cell_node_scale_alpha.md) : Set the cell plot node alpha scale - [`cell_node_depth()`](cell_node_depth.md) : Set the cell plot node depth scale - [`cell_illuminate()`](cell_illuminate.md) : Add illumination to a cell plot - [`cell_theme()`](cell_theme.md) : Set the cell plot theme - [`cell_annotation()`](cell_annotation.md) : Annotate a cell plot - [`cell_coord_rotate()`](cell_coord_rotate.md) : Add rotating coordinates to a cell plot - [`cell_plot_interactive()`](cell_plot_interactive.md) : Render a cell plot as an interactive 3D widget - [`cell_plot_animate()`](cell_plot_animate.md) : Render a rotating cell plot animation ### Graph layouts - [`ComputeLayout()`](ComputeLayout.md) : Compute a graph layout - [`layout_with_spectral()`](layout_with_spectral.md) : Spectral Layout via Graph Laplacian - [`layout_with_weighted_pmds()`](layout_with_weighted_pmds.md) : Weighted PMDS - [`layout_with_coarsened_pmds()`](layout_with_coarsened_pmds.md) : Coarsened pMDS - [`center_layout_coordinates()`](layout_coordinates_utils.md) [`normalize_layout_coordinates()`](layout_coordinates_utils.md) [`project_layout_coordinates_on_unit_sphere()`](layout_coordinates_utils.md) : Layout Coordinates Utility Functions - [`render_rotating_layout()`](render_rotating_layout.md) **\[deprecated\]** : Create a rotating 3D layout video - [`scale_layout()`](scale_layout.md) : Scale layout coordinates - [`fast_pmds()`](fast_pmds.md) : Fast pMDS implementation using RSpectra ### Data processing - [`NormalizeMPX()`](NormalizeMPX.md) **\[superseded\]** : Normalize MPX data - [`FindAbundantMarkers()`](FindAbundantMarkers.md) : Find abundant markers by isotype-relative and/or absolute abundance - [`KeepLargestComponent()`](KeepLargestComponent.md) : Keep largest component - [`RemoveCellGraphs()`](RemoveCellGraphs.md) : Remove CellGraphs - [`LoadCellGraphs()`](LoadCellGraphs.md) : Load CellGraphs - [`CalculateDispersion()`](CalculateDispersion.md) : Calculate dispersion of components - [`ComputeProximityScores()`](ComputeProximityScores.md) : Compute proximity scores - [`SequenceSaturationCurve()`](SequenceSaturationCurve.md) : Simulate Sequencing Saturation Curve - [`approximate_edge_saturation()`](approximate_edge_saturation.md) : Compute approximate edge saturation - [`approximate_node_saturation()`](approximate_node_saturation.md) : Compute approximate node saturation - [`approximate_saturation_curve()`](approximate_saturation_curve.md) : Compute approximate saturation curve - [`sequencing_saturation()`](sequencing_saturation.md) : Calculate Sequencing Saturation - [`marginal_saturation()`](marginal_saturation.md) : Compute marginal discovery rate and saturation - [`marginal_saturation_curve()`](marginal_saturation_curve.md) : Compute marginal discovery rate and saturation curve - [`downsample_to_parquet()`](downsample_to_parquet.md) : Downsample edgelist and export to parquet files - [`lcc_curve()`](lcc_curve.md) **\[experimental\]** : Compute LCC curve for downsampled edgelists - [`lcc_sizes()`](lcc_sizes.md) : Compute LCC sizes from downsampled edgelists - [`isotype_pls()`](isotype_pls.md) : Partial Least Squares Regression for background factor regression - [`cos_dist()`](cos_dist.md) : Calculate cosine distances between two sets of coordinates - [`pack_2bits()`](two_bit_encoding.md) [`unpack_2bits()`](two_bit_encoding.md) : Encode/decode DNA sequences ### Differential analysis - [`RunDAA()`](RunDAA.md) : Differential analysis (abundance) - [`RunDPA()`](RunDPA.md) : Differential analysis (polarity) - [`RunDCA()`](RunDCA.md) : Differential analysis (colocalization) - [`DifferentialProximityAnalysis()`](DifferentialProximityAnalysis.md) : Differential analysis of proximity scores - [`FindAllProximityMarkers()`](FindAllProximityMarkers.md) : Find all proximity markers - [`add_proximity_transition()`](add_proximity_transition.md) : Add a proximity transition column to differential proximity results - [`ColocalizationHeatmap()`](ColocalizationHeatmap.md) : Plot a colocalization heatmap ### Cell type annotation - [`AnnotateCells()`](AnnotateCells.md) : Automatic annotation of cell types ### Proximity scores - [`PolarizationScoresToAssay()`](PolarizationScoresToAssay.md) : Convert polarization score table to an Assay or Assay5 - [`ColocalizationScoresToAssay()`](ColocalizationScoresToAssay.md) : Convert colocalization score table to an Assay or Assay5 - [`ProximityScoresToAssay()`](ProximityScoresToAssay.md) : Convert proximity score table to an Assay or Assay5 - [`FilterProximityScores()`](FilterProximityScores.md) : Filter proximity scores - [`SummarizeProximityScores()`](SummarizeProximityScores.md) : Summarize proximity scores - [`local_proximity()`](local_proximity.md) : Compute local proximity scores ### Cell segmentation - [`segment_cell()`](segment_cell.md) : cell:cell conjugate segmentation - [`cc_protein_weights()`](cc_protein_weights.md) : Derive protein weights for two cell populations - [`distance_from_node_set()`](distance_from_node_set.md) : Compute distance from a set of seed nodes using fast breadth-first search. - [`partition_counts()`](partition_counts.md) : Compute partition counts - [`spatial_smoothing()`](spatial_smoothing.md) : Perform spatial smoothing of a count matrix using the adjacency matrix of the graph - [`fetch_node_neighborhoods()`](fetch_node_neighborhoods.md) : Fetch node neighborhoods from pxl file(s) attached to a Seurat object ### Doublet detection - [`FindAnnoyNeighbors()`](FindAnnoyNeighbors.md) : Approximate nearest neighbors using Annoy - [`SimulateDoublets()`](SimulateDoublets.md) : Simulate doublets - [`PredictDoublets()`](PredictDoublets.md) **\[experimental\]** : Predict doublets in a Seurat object ### Patch analysis - [`identify_markers_for_patch_analysis()`](identify_markers_for_patch_analysis.md) : Identify population-specific markers for patch detection - [`patch_detection()`](patch_detection.md) **\[experimental\]** : Supervised patch detection ### CellGraphAssay(5), PNAAssay(5) and CellGraph methods - [`RenameCells(`*``*`)`](CellGraphAssay-methods.md) [`show(`*``*`)`](CellGraphAssay-methods.md) [`subset(`*``*`)`](CellGraphAssay-methods.md) [`merge(`*``*`)`](CellGraphAssay-methods.md) : CellGraphAssay Methods - [`RenameCells(`*``*`)`](CellGraphAssay5-methods.md) [`show(`*``*`)`](CellGraphAssay5-methods.md) [`subset(`*``*`)`](CellGraphAssay5-methods.md) [`merge(`*``*`)`](CellGraphAssay5-methods.md) [`JoinLayers(`*``*`)`](CellGraphAssay5-methods.md) : CellGraphAssay5 Methods - [`RenameCells(`*``*`)`](PNAAssay-methods.md) [`show(`*``*`)`](PNAAssay-methods.md) [`subset(`*``*`)`](PNAAssay-methods.md) [`merge(`*``*`)`](PNAAssay-methods.md) : PNAAssay Methods - [`RenameCells(`*``*`)`](PNAAssay5-methods.md) [`show(`*``*`)`](PNAAssay5-methods.md) [`subset(`*``*`)`](PNAAssay5-methods.md) [`merge(`*``*`)`](PNAAssay5-methods.md) [`JoinLayers(`*``*`)`](PNAAssay5-methods.md) : PNAAssay5 Methods - [`RenameCells(`*``*`)`](MPXAssay-methods.md) [`show(`*``*`)`](MPXAssay-methods.md) [`subset(`*``*`)`](MPXAssay-methods.md) [`merge(`*``*`)`](MPXAssay-methods.md) : MPXAssay Methods - [`CreateCellGraphAssay()`](CreateCellGraphAssay.md) : Create a CellGraphAssay object - [`CreateCellGraphAssay5()`](CreateCellGraphAssay5.md) : Create a CellGraphAssay5 object - [`CreatePNAAssay()`](CreatePNAAssay.md) : Create a PNAAssay object - [`CreatePNAAssay5()`](CreatePNAAssay5.md) : Create a PNAAssay5 object - [`CellGraphs()`](CellGraphs.md) [`` `CellGraphs<-`() ``](CellGraphs.md) : CellGraphs - [`PolarizationScores()`](PolarizationScores.md) [`` `PolarizationScores<-`() ``](PolarizationScores.md) : PolarizationScores - [`ColocalizationScores()`](ColocalizationScores.md) [`` `ColocalizationScores<-`() ``](ColocalizationScores.md) : ColocalizationScores - [`ProximityScores()`](ProximityScores.md) [`` `ProximityScores<-`() ``](ProximityScores.md) : ProximityScores - [`Edgelists()`](Edgelists.md) : Load edgelists - [`Normalize()`](Normalize.md) : Normalize MPX or PNA data - [`FSMap()`](FSMap.md) [`` `FSMap<-`() ``](FSMap.md) : FS map - [`RestorePaths()`](RestorePaths.md) : Restore PXL file paths - [`CellGraphData()`](CellGraphData.md) [`` `CellGraphData<-`() ``](CellGraphData.md) : Get and set CellGraph object data - [`as.CellGraphAssay()`](as.CellGraphAssay.md) : Convert objects to a `CellGraphAssay` - [`as.CellGraphAssay5()`](as.CellGraphAssay5.md) : Convert objects to a `CellGraphAssay5` - [`as.PNAAssay()`](as.PNAAssay.md) : Convert objects to a `PNAAssay` - [`as.PNAAssay5()`](as.PNAAssay5.md) : Convert objects to a `PNAAssay5` - [`CellGraph-class`](CellGraph-class.md) [`CellGraph`](CellGraph-class.md) : The CellGraph class - [`CreateCellGraphObject()`](CreateCellGraphObject.md) : Create a CellGraph object - [`CreateCellGraphList()`](CellGraphList.md) : The CellGraphList class - [`print(`*``*`)`](CellGraphList-methods.md) [`` `[`( ``*``*`)`](CellGraphList-methods.md) [`` `[<-`( ``*``*`)`](CellGraphList-methods.md) [`` `[[<-`( ``*``*`)`](CellGraphList-methods.md) [`` `names<-`( ``*``*`)`](CellGraphList-methods.md) [`c(`*``*`)`](CellGraphList-methods.md) [`as.list(`*``*`)`](CellGraphList-methods.md) : CellGraphList Methods - [`FetchLayoutData()`](FetchLayoutData.md) : Fetch graph layout coordinates - [`ComputeLPS()`](ComputeLPS.md) : Compute local proximity scores - [`show(`*``*`)`](NodeDimReduc-methods.md) [`Embeddings(`*``*`)`](NodeDimReduc-methods.md) [`Loadings(`*``*`)`](NodeDimReduc-methods.md) [`Stdev(`*``*`)`](NodeDimReduc-methods.md) [`Key(`*``*`)`](NodeDimReduc-methods.md) [`Cells(`*``*`)`](NodeDimReduc-methods.md) : NodeDimReduc Methods - [`CreateNodeDimReducObject()`](CreateNodeDimReducObject.md) : Create a NodeDimReduc object ### Graph functions - [`edgelist_to_simple_Anode_graph()`](graph-conversion.md) **\[deprecated\]** : A-node projection - [`edgelist_to_simple_bipart_graph()`](edgelist_to_simple_bipart_graph.md) : Create a simple bipartite graph from an edgelist - [`node_markers_counts()`](node_markers_counts.md) **\[deprecated\]** : Calculate antibody counts per A-node - [`compute_transition_probabilities()`](compute_transition_probabilities.md) : Compute transition probabilities - [`cos_distance_weights()`](edge-weights-pmds.md) [`prob_distance_weights()`](edge-weights-pmds.md) **\[experimental\]** : Calculate edge weights for pMDS - [`local_G()`](local_G.md) : Calculate Local G - [`expand_adjacency_matrix()`](expand_adjacency_matrix.md) : Expand an adjacency matrix to include higher-order neighborhoods ### Export - [`WriteMPX_pxl_file()`](WriteMPX_pxl_file.md) **\[experimental\]** : Export Seurat object MPX data to a PXL file ### Classes - [`CellGraphAssay-class`](CellGraphAssay-class.md) [`CellGraphAssay`](CellGraphAssay-class.md) : The CellGraphAssay class - [`CellGraphAssay5-class`](CellGraphAssay5-class.md) [`CellGraphAssay5`](CellGraphAssay5-class.md) : The CellGraphAssay5 class - [`MPXAssay-class`](MPXAssay-class.md) [`MPXAssay`](MPXAssay-class.md) : MPXAssay class - [`PNAAssay-class`](PNAAssay-class.md) [`PNAAssay`](PNAAssay-class.md) : The PNAAssay class - [`PNAAssay5-class`](PNAAssay5-class.md) [`PNAAssay5`](PNAAssay5-class.md) : The PNAAssay5 class - [`NodeDimReduc-class`](NodeDimReduc-class.md) [`NodeDimReduc`](NodeDimReduc-class.md) : The NodeDimReduc class ### Colors - [`PixelgenAccentColors()`](PixelgenAccentColors.md) : Get Pixelgen accent colors - [`PixelgenGradient()`](PixelgenGradient.md) : Get Pixelgen gradient colors - [`PixelgenPalette()`](PixelgenPalette.md) : Get Pixelgen palette colors - [`Pixelgen_accent_colors`](Pixelgen_accent_colors.md) : Pixelgen accent colors - [`show_accent_colors()`](show_accent_colors.md) : Show accent colors - [`color_discrete_pixelgen()`](color-themes.md) [`color_sequential_pixelgen()`](color-themes.md) [`color_divergent_pixelgen()`](color-themes.md) : Pixelgen ggplot2 color themes - [`create_discrete_palette()`](create_discrete_palette.md) : Create sample palette - [`theme_pixelgen()`](theme_pixelgen.md) : Pixelgen theme - [`Pixelgen_cell_palette`](Pixelgen_cell_palette.md) : Pixelgen cell type colors - [`heuristic_illumination()`](heuristic_illumination.md) : Compute heuristic illumination for 3D layouts ### Misc - [`pixelatorR_options`](pixelatorR_options.md) : Global Options in pixelatorR - [`pixelatorR-package`](pixelatorR-package.md) : pixelatorR: Data Structures, Data Processing Tools and Visualization Tools for MPX Single Cell Data - [`minimal_mpx_pxl_file()`](mpx_dataset.md) : Five Cells MPX Test data - [`minimal_pna_pxl_file()`](pna_dataset.md) : Five Cells PNA Test data - [`Layers(`*``*`)`](CellGraph-methods.md) [`LayerData(`*``*`)`](CellGraph-methods.md) [`` `LayerData<-`( ``*``*`)`](CellGraph-methods.md) [`Embeddings(`*``*`)`](CellGraph-methods.md) [`Loadings(`*``*`)`](CellGraph-methods.md) [`Stdev(`*``*`)`](CellGraph-methods.md) [`AddMetaData(`*``*`)`](CellGraph-methods.md) [`FetchData(`*``*`)`](CellGraph-methods.md) [`show(`*``*`)`](CellGraph-methods.md) [`` `[[`( ``*``*`,`*``*`,`*``*`)`](CellGraph-methods.md) [`` `[[<-`( ``*``*`,`*``*`,`*``*`,`*``*`)`](CellGraph-methods.md) [`subset(`*``*`)`](CellGraph-methods.md) [`FetchData(`*``*`)`](CellGraph-methods.md) : CellGraph Methods - [`RenameCells(`*``*`)`](CellGraphAssay-methods.md) [`show(`*``*`)`](CellGraphAssay-methods.md) [`subset(`*``*`)`](CellGraphAssay-methods.md) [`merge(`*``*`)`](CellGraphAssay-methods.md) : CellGraphAssay Methods - [`inspect_pxl_file()`](inspect_pxl_file.md) : Inspect a PXL file with MPX data - [`pixelatorR_style()`](pixelatorR_style.md) : The pixelatorR style - [`print(`*``*`)`](print.pixelator_metadata.md) : Print method for pixelator_metadata - [`assert_single_value()`](type_check_helpers.md) [`assert_vector()`](type_check_helpers.md) [`assert_class()`](type_check_helpers.md) [`assert_mpx_assay()`](type_check_helpers.md) [`assert_pna_assay()`](type_check_helpers.md) [`assert_pixel_assay()`](type_check_helpers.md) [`assert_within_limits()`](type_check_helpers.md) [`assert_function()`](type_check_helpers.md) [`assert_file_exists()`](type_check_helpers.md) [`assert_file_ext()`](type_check_helpers.md) [`assert_x_in_y()`](type_check_helpers.md) [`assert_single_values_are_different()`](type_check_helpers.md) [`assert_singles_match()`](type_check_helpers.md) [`assert_length()`](type_check_helpers.md) [`assert_max_length()`](type_check_helpers.md) [`assert_vectors_x_y_length_equal()`](type_check_helpers.md) [`assert_unique()`](type_check_helpers.md) [`assert_col_class()`](type_check_helpers.md) [`assert_col_in_data()`](type_check_helpers.md) [`assert_non_empty_object()`](type_check_helpers.md) [`assert_is_one_of()`](type_check_helpers.md) [`assert_different()`](type_check_helpers.md) [`assert_vectors_match()`](type_check_helpers.md) [`assert_valid_color()`](type_check_helpers.md) : Type check helpers - [`export_plot()`](export_plot.md) : Save a ggplot2 plot to one or more file formats with options for size and directory creation. # Articles ### All vignettes - [Introduction](introduction.md): - [Load data](load_data.md):