| scatter_plot | R Documentation |
Generic function for creating scatter plots. Methods available for NCM result objects and data frames.
scatter_plot(object, ...)
## S3 method for class 'NCM'
scatter_plot(
object,
point_alpha = 0.8,
point_size = 3,
point_colors = c(Above = "#ED7D70", Below = "#2B889B", Neutral = "#B57FAF"),
fit_line_color = "#335399",
fit_line_type = "solid",
fit_line_size = 1,
ci_line_color = "#335399",
ci_line_type = "dashed",
ci_line_size = 1,
axis_title_x_text = "Mean relative abundance (log10)",
axis_title_y_text = "Frequency of occupancy",
axis_title_x_size = 25,
axis_title_y_size = 25,
axis_text_x_size = 20,
axis_text_y_size = 20,
legend_title_text = NA,
legend_size = 6,
legend_position = c(0.8, 0.4),
legend_hjust = 0,
legend_vjust = 1,
fit_para_size = 6,
fit_para_position = c(0.02, 0.98),
fit_para_hjust = 0,
fit_para_vjust = 1,
font_family = "sans",
...
)
## S3 method for class 'data.frame'
scatter_plot(
object,
rsqr,
Nm,
m,
map,
point_alpha = 0.8,
point_size = 3,
point_colors = c(Above = "#ED7D70", Below = "#2B889B", Neutral = "#B57FAF"),
fit_line_color = "#335399",
fit_line_type = "solid",
fit_line_size = 1,
ci_line_color = "#335399",
ci_line_type = "dashed",
ci_line_size = 1,
axis_title_x_text = "Mean relative abundance (log10)",
axis_title_y_text = "Frequency of occupancy",
axis_title_x_size = 25,
axis_title_y_size = 25,
axis_text_x_size = 20,
axis_text_y_size = 20,
legend_title_text = NA,
legend_size = 6,
legend_position = c(0.8, 0.4),
legend_hjust = 0,
legend_vjust = 1,
fit_para_size = 6,
fit_para_position = c(0.02, 0.98),
fit_para_hjust = 0,
fit_para_vjust = 1,
font_family = "sans",
...
)
## Default S3 method:
scatter_plot(object, ...)
object |
An object to plot: NCM result or data.frame |
... |
Additional arguments passed to methods |
point_alpha |
Alpha transparency for points (default: 0.8) |
point_size |
Point size (default: 3) |
point_colors |
Named vector of colors for Above/Below/Neutral status |
fit_line_color |
Fitted line color (default: "#335399") |
fit_line_type |
Line type for fitted curve (default: "solid") |
fit_line_size |
Line width for fitted curve (default: 1) |
ci_line_color |
Confidence interval line color (default: "#335399") |
ci_line_type |
Confidence interval line type (default: "dashed") |
ci_line_size |
Confidence interval line width (default: 1) |
axis_title_x_text |
X-axis title text |
axis_title_y_text |
Y-axis title text |
axis_title_x_size |
X-axis title font size (default: 25) |
axis_title_y_size |
Y-axis title font size (default: 25) |
axis_text_x_size |
X-axis tick label font size (default: 20) |
axis_text_y_size |
Y-axis tick label font size (default: 20) |
legend_title_text |
Legend title text (default: NA) |
legend_size |
Legend text size (default: 6) |
legend_position |
Legend position as NPC coordinates c(x, y) (default: c(0.80, 0.40)) |
legend_hjust |
Legend horizontal justification (default: 0) |
legend_vjust |
Legend vertical justification (default: 1) |
fit_para_size |
Fitting parameter text size (default: 6) |
fit_para_position |
Parameter annotation position as NPC coordinates c(x, y) (default: c(0.02, 0.98)) |
fit_para_hjust |
Parameter horizontal justification (default: 0) |
fit_para_vjust |
Parameter vertical justification (default: 1) |
font_family |
Font family (default: "sans") |
rsqr |
R-squared value from NCM fit |
Nm |
Nm parameter from NCM fit |
m |
m parameter from NCM fit |
map |
Named vector for column name mapping (e.g., c(p = "abundance")) |
A ggplot object
scatter_plot(NCM): Plot NCM result with fitted curve, confidence
intervals, and parameter annotations. Supports full customization of
visual elements.
scatter_plot(data.frame): Plot data.frame by converting to NCM object.
Requires manual specification of model parameters (rsqr, Nm, m) and
optional column name mapping.
scatter_plot(default): Default method for unsupported types.
# Load example data
data(example_data)
otu <- example_data$otu
# fit the total model using all samples
res_total <- fit_ncm(otu)
# plot
scatter_plot(res_total)
# Load example data
data(example_data)
otu <- example_data$otu
# fit the total model using all samples
res_total <- fit_ncm(otu)
df <- res_total$predictions
# Plot with manual parameters
scatter_plot(df, rsqr = 0.95, Nm = 500, m = 0.5678)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.