
Weighted PMDS
layout_with_weighted_pmds.Rd
This function is a wrapper around layout_with_pmds
from
the graphlayouts
R package, and can be used to compute a pmds
layout of a graph with edge weights.
Usage
layout_with_weighted_pmds(
g,
dim = 2,
method = c("prob_dist", "cos_dist"),
pivots = 200,
pow = 3,
seed = 123
)
Arguments
- g
An
igraph
or atbl_graph
object- dim
Desired number of dimensions. Can be 2 or 3
- method
Edge weighting method to use for computing the layout. Can be either "prob_dist" or "cos_dist".
- pivots
Number of pivots
- pow
Power to raise the distance weights to. Increasing this value will amplify higher distance weights. Default is 3.
- seed
Set seed for pivot sampling
weights
prob_dist : see
cos_distance_weights
cos_dist : see
prob_distance_weights
Examples
library(dplyr)
pxl_file <- minimal_mpx_pxl_file()
seur_obj <- ReadMPX_Seurat(pxl_file) %>%
LoadCellGraphs(cells = colnames(.)[1])
#> ✔ Created a 'Seurat' object with 5 cells and 80 targeted surface proteins
#> → Loading CellGraphs for 1 cells from sample 1
#> ✔ Successfully loaded 1 CellGraph object(s).
# compute weighted pMDS layout
g <- CellGraphs(seur_obj)[[1]] %>%
CellGraphData("cellgraph")
layout <- layout_with_weighted_pmds(g, dim = 3) %>%
as_tibble(.name_repair = ~ c("x", "y", "z"))
plotly::plot_ly(
layout,
x = ~x,
y = ~y,
z = ~z,
size = 1,
type = "scatter3d",
mode = "markers"
)
# or using ComputeLayout and Plot3DGraph
seur_obj <- seur_obj %>%
# Compute weighted pMDS layout
ComputeLayout(layout_method = "wpmds", dim = 3)
#> ℹ Computing layouts for 1 graphs
# Create 3D plot
Plot3DGraph(seur_obj,
layout_method = "wpmds_3d",
cell_id = colnames(seur_obj)[1],
marker = "CD3E"
)