Package 'linkmapper'

Title: Point-and-Click Linkage Mapping and QTL Analysis
Description: A 'shiny' application and a set of plain R functions for building genetic linkage maps and locating quantitative trait loci in F2 intercross, backcross and recombinant inbred line populations. It wraps 'onemap' (Margarido et al. 2007 <doi:10.1111/j.2007.0018-0661.02000.x>) for segregation tests, two-point analysis, grouping, ordering and map estimation, and 'qtl' (Broman et al. 2003 <doi:10.1093/bioinformatics/btg112>) for interval mapping and composite interval mapping with permutation thresholds. Results can be exported as figures, tables, a self-contained HTML report and an R script that reproduces the analysis.
Authors: Ebenezer Ogoe [aut, cre, cph] (Co-creator; wrote the 2026 package), Michael Obeng [aut, cph] (Co-creator of Linkmapper (2022)), Stephen Amoako [aut, cph] (Co-creator of Linkmapper (2022))
Maintainer: Ebenezer Ogoe <[email protected]>
License: MIT + file LICENSE
Version: 0.2.0
Built: 2026-10-14 22:33:31 UTC
Source: https://github.com/ebenogoe/linkmapper

Help Index


Add trait values to a dataset

Description

Reads a CSV with one row per individual, in the same order as in the genotype file, and one numeric column per trait. A first column named id, individual or ind is ignored.

Usage

add_traits(d, path)

Arguments

d

An lm_data object.

path

Path to the CSV file.

Value

d with the traits in d$onemap$pheno (replacing any traits from the genotype file).


Build an R/qtl cross from a Linkmapper map

Description

Writes the mapped markers and the traits in MAPMAKER format, writes the map with onemap::write_map(), and reads both with qtl::read.cross(). Chromosomes are the linkage groups in map order.

Usage

build_cross(d, m)

Arguments

d

The lm_data the map was built from.

m

An lm_map from order_groups().

Value

An R/qtl cross object.


Write a self-contained HTML report

Description

Write a self-contained HTML report

Usage

build_report(res, settings = list(), path, title = "Linkmapper report")

Arguments

res

A list with any of raw, data, qc, groups, map and qtl, as produced by the app or by run_analysis().

settings

The settings list.

path

Output file.

title

Report title.

Value

path, invisibly.


Write an R script that repeats an analysis

Description

Write an R script that repeats an analysis

Usage

build_script(settings, source)

Arguments

settings

A settings list.

source

List with demo (a demo name) or file, and optionally traits (trait file name).

Value

A character string of R code.


Default analysis settings

Description

Every step of the app is described by one entry in this list. The app fills it in as you go, run_analysis() replays it, and build_script() turns it into R code.

Usage

default_settings(d = NULL)

Arguments

d

Optional lm_data, used to pick the first trait.

Value

A named list.


Demo datasets

Description

The F2 and backcross demos are the simulated example data shipped with onemap (200 and 150 individuals, one trait each). The RIL demo is onemap's selfed RIL example (100 lines, no traits). small is the 20-individual F2 file from the 2022 Linkmapper.

Usage

demo_info()

linkmapper_demo(name = c("f2", "bc", "ril", "small"))

Arguments

name

One of demo_info()$name.

Value

demo_info() returns a data frame describing each dataset.

linkmapper_demo() returns an lm_data object.


Filter markers

Description

Filter markers

Usage

filter_markers(d, max_missing = 0.25, drop_distorted = FALSE, alpha = 0.05)

Arguments

d

An lm_data object.

max_missing

Largest share of missing genotypes allowed per marker.

drop_distorted

Remove markers with significant segregation distortion (Bonferroni-corrected).

alpha

Family-wise significance level for distortion.

Value

The filtered lm_data, with a filter element recording what was removed.


Trait values by genotype at a marker

Description

Trait values by genotype at a marker

Usage

genotype_effect(res, marker)

Arguments

res

An lm_qtl from scan_qtl().

marker

Marker name.

Value

A data frame with genotype and value.


Group markers (Linkmapper 0.1 interface)

Description

Kept for scripts written for Linkmapper 0.1. Prefer linkage_groups().

Usage

group_markers(onemap_obj, lod = 3, max_rf = 0.5, map_fun = "kosambi")

Arguments

onemap_obj

A onemap object.

lod

LOD threshold.

max_rf

Largest recombination fraction treated as linkage.

map_fun

"kosambi" or "haldane".

Value

The onemap group object.


Find linkage groups

Description

Runs two-point analysis on every pair of markers and groups markers that are linked at or above the LOD threshold and at or below the maximum recombination fraction.

Usage

linkage_groups(d, lod = NULL, max_rf = 0.5)

Arguments

d

An lm_data object.

lod

LOD threshold. Defaults to suggest_lod().

max_rf

Largest recombination fraction treated as linkage.

Value

An lm_groups list with the onemap twopts and groups objects and a table of groups.

Examples

g <- linkage_groups(linkmapper_demo("bc"))
g$table

Size of a linkage map figure in inches

Description

Size of a linkage map figure in inches

Usage

map_plot_size(m)

Arguments

m

An lm_map.

Value

c(width, height).


Marker positions on a map

Description

Marker positions on a map

Usage

map_positions(m)

Arguments

m

An lm_map from order_groups().

Value

A data frame with one row per marker: linkage group, order, marker, position (cM) and distance to the previous marker.


Summary of each linkage group

Description

Summary of each linkage group

Usage

map_summary(m)

Arguments

m

An lm_map.

Value

A data frame with markers, length, mean and largest spacing per group.


Order markers within each linkage group

Description

Orders each group with the chosen algorithm and estimates map distances with the chosen mapping function. Groups with fewer than two markers cannot be ordered and are reported as unplaced.

Usage

order_groups(
  groups,
  method = "record",
  map_fun = c("kosambi", "haldane"),
  seed = 1,
  progress = NULL
)

Arguments

groups

An lm_groups object from linkage_groups().

method

One of order_methods().

map_fun

"kosambi" or "haldane".

seed

Random seed. RECORD and UG use random starting orders, so the seed makes the map repeatable.

progress

Optional function called with the share done (0 to 1).

Value

An lm_map list with the ordered onemap sequences (maps), a positions table and settings.


Ordering algorithms

Description

Ordering algorithms

Usage

order_methods()

Value

A named character vector (labels as names).


Trait values by genotype

Description

Trait values by genotype

Usage

plot_effect(df, marker, trait, dark = FALSE)

Arguments

df

Result of genotype_effect().

marker

Marker name, for the title.

trait

Trait name, for the axis.

dark

Colours for a dark background.

Value

A ggplot object.


Draw a linkage map

Description

Each linkage group is a vertical bar with positions (cM) on the left and marker names on the right. Labels are spread so they do not overlap. QTL support intervals from scan_qtl() can be drawn beside the groups.

Usage

plot_linkage_map(m, qtl = NULL, dark = FALSE, label_size = 2.9, title = NULL)

Arguments

m

An lm_map from order_groups(), or any list with a positions data frame (columns lg, marker, position).

qtl

Optional lm_qtl from scan_qtl(), or a list with a peaks data frame and a trait.

dark

Colours for a dark background.

label_size

Text size.

title

Optional title.

Value

A ggplot object (interactive with ggiraph::girafe()).


LOD profile plot

Description

LOD profile plot

Usage

plot_lod(res, dark = FALSE)

Arguments

res

An lm_qtl from scan_qtl().

dark

Colours for a dark background.

Value

A ggplot object.


Missing data plot

Description

Missing data plot

Usage

plot_missing(q, threshold = NULL, dark = FALSE)

Arguments

q

Result of qc_summary().

threshold

Optional cut-off to draw.

dark

Colours for a dark background.

Value

A ggplot object.


Recombination fraction heatmap for one linkage group

Description

Markers are in map order. Darker cells mean tighter linkage.

Usage

plot_rf_heatmap(m, lg, dark = FALSE)

Arguments

m

An lm_map.

lg

Linkage group name, for example "LG1".

dark

Colours for a dark background.

Value

A ggplot object.


Segregation test plot

Description

Segregation test plot

Usage

plot_segregation(q, dark = FALSE)

Arguments

q

Result of qc_summary().

dark

Colours for a dark background.

Value

A ggplot object.


Marker and individual quality summary

Description

Missing data per marker and per individual, genotype counts, and the chi-square test of each marker against its expected Mendelian ratio (1:2:1, 3:1, 1:1). The significance threshold is Bonferroni-corrected for the number of markers.

Usage

qc_summary(d, alpha = 0.05)

Arguments

d

An lm_data object.

alpha

Family-wise significance level for segregation distortion.

Value

A list with markers and individuals data frames and the corrected threshold alpha_bonferroni.


QTL mapping methods

Description

QTL mapping methods

Usage

qtl_methods()

Value

A named character vector (labels as names).


Read a genotype file

Description

Reads MAPMAKER files (.raw or .txt, as used by MAPMAKER/EXP and R/qtl) and onemap raw files. Supported populations are F2 intercross, backcross, and recombinant inbred lines from selfing or sib mating.

Usage

read_cross(path, name = basename(path))

Arguments

path

Path to the file.

name

Original file name, if path is a temporary upload.

Value

An lm_data object holding the onemap object, the population type and the file contents.

Examples

d <- read_cross(system.file("extdata", "mapmaker_example_bc.raw", package = "onemap"))
d

Run a whole analysis from settings

Description

Run a whole analysis from settings

Usage

run_analysis(d, settings = default_settings(d), progress = NULL)

Arguments

d

An lm_data object as read.

settings

A list like default_settings(). Steps whose entry is NULL are skipped.

progress

Optional function called with a message at each step.

Value

A list with data, groups, map, cross and qtl.


Run the Linkmapper app

Description

run_linkmapper() is the name used in Linkmapper 0.1 and still works.

Usage

run_app(
  onStart = NULL,
  options = list(),
  enableBookmarking = NULL,
  uiPattern = "/",
  ...
)

run_linkmapper(...)

Arguments

onStart, options, enableBookmarking, uiPattern

Passed to shiny::shinyApp().

...

Options passed to the app as golem options.

Value

A Shiny app object.

Examples

if (interactive()) run_app()

Save and restore an analysis session

Description

A session file is JSON holding the genotype file contents, any traits and the settings. Results are recomputed when the session is opened.

Usage

save_session(d, settings, path)

load_session(path)

Arguments

d

The lm_data as read (with traits, if added).

settings

The settings list.

path

File to write or read.

Value

save_session() returns path invisibly; load_session() returns a list with data and settings.


Scan for QTL

Description

Interval mapping (qtl::scanone()) or composite interval mapping (qtl::cim()) for one trait, with a genome-wide LOD threshold from permutations (Churchill and Doerge 1994). For each linkage group whose highest LOD passes the threshold, the peak is reported with its 1.5-LOD support interval, nearest marker, genome-wide p-value, percentage of phenotypic variance explained and estimated effects.

Usage

scan_qtl(
  cross,
  trait = NULL,
  method = "hk",
  cim = FALSE,
  n_marcovar = 3,
  window = 10,
  n_perm = 1000,
  alpha = 0.05,
  step = 1,
  seed = 1,
  progress = NULL
)

Arguments

cross

A cross from build_cross().

trait

Trait name.

method

One of qtl_methods().

cim

Use composite interval mapping.

n_marcovar, window

Marker covariates and window (cM) for CIM.

n_perm

Number of permutations.

alpha

Genome-wide significance level.

step

Spacing (cM) of the scan.

seed

Random seed.

progress

Optional function called with the share done (0 to 1).

Value

An lm_qtl list.


Suggest a LOD threshold

Description

Uses onemap's suggestion, which accounts for the number of tests made in the two-point analysis.

Usage

suggest_lod(d)

Arguments

d

An lm_data object.

Value

A number.


ggplot2 theme used by Linkmapper

Description

ggplot2 theme used by Linkmapper

Usage

theme_linkmapper(base_size = 12, dark = FALSE)

Arguments

base_size

Base font size.

dark

Use colours for a dark background.

Value

A ggplot2 theme.


Check that a file can be read

Description

Kept from Linkmapper 0.1 for scripts that use it. Prefer read_cross().

Usage

validate_lm_file(path)

Arguments

path

Path to a MAPMAKER or onemap file.

Value

A onemap object.


Write a dataset in MAPMAKER format

Description

Used to pass data from onemap to R/qtl, and useful for exporting a filtered dataset.

Usage

write_mapmaker(d, file)

Arguments

d

An lm_data object.

file

Output path.

Value

file, invisibly.