Skip to content

R Package

Overview

The MyoScore R package provides a streamlined interface for calculating the Genetic Muscle Health Score (GMHS v3.3) from bulk RNA-seq raw count data. It includes built-in gene weights, preprocessing, scoring, and visualization functions.

INFO

Package: MyoScore v1.0.0 | License: MIT | R: >= 4.0.0

Installation

r
# Install from GitHub
devtools::install_github("Hirriririir/MyoScore")

Quick Start

r
library(MyoScore)

# Calculate MyoScore from a CSV file (genes as rows, samples as columns)
scores <- myoscore_score("path/to/raw_counts.csv")

# Or from a matrix already in R
scores <- myoscore_score(count_matrix)

# For tab-separated files
scores <- myoscore_score("counts.tsv", sep = "\t")

# View results
head(scores)
#>     Strength_score Mass_score LeanMuscle_score Youth_score Resilience_score MyoScore
#> S1          72.3       65.1             80.2        55.8             68.4     69.2
#> S2          45.1       38.7             42.3        61.2             35.6     44.1

Input Requirements

  • Format: Raw count matrix (not TPM, FPKM, or normalized values)
  • Genes: Gene Symbols as row names (not Ensembl IDs)
  • Samples: At least 2 samples (recommend >= 20 for reliable normalization)
  • Coverage: Typical bulk RNA-seq datasets contain ~417 of the 1,116 scoring genes (~50% per dimension), which is sufficient for reliable scoring

Functions Reference

myoscore_score() — Main Scoring Function

The primary entry point. Accepts a file path or count matrix and returns per-sample scores.

r
myoscore_score(
  input,               # File path (CSV/TSV) or count matrix/data.frame
  gene_weights = NULL, # Custom gene weights (default: built-in)
  sep = ",",           # File separator
  min_coverage = 0.1,  # Minimum gene coverage fraction per dimension
  verbose = TRUE       # Print progress messages
)

Returns: A data.frame with columns: Strength_score, Mass_score, LeanMuscle_score, Youth_score, Resilience_score, MyoScore (all 0-100).

Scoring Pipeline:

  1. Raw counts normalized to log2(CPM+1)
  2. Gene-wise z-score standardization across all input samples
  3. Z-scores multiplied by gene direction and weight, then averaged (weighted mean)
  4. Min-max normalization to 0-100 per dimension
  5. Composite score = weighted sum of five dimensions

myoscore_preprocess() — Normalization

Normalize raw counts to log2(CPM+1).

r
log2cpm <- myoscore_preprocess(count_matrix, verbose = TRUE)

myoscore_score_dimension() — Single Dimension

Calculate the score for a single dimension.

r
log2cpm <- myoscore_preprocess(count_matrix)
youth <- myoscore_score_dimension(log2cpm, dimension = "Youth")

Available dimensions: "Strength", "Mass", "LeanMuscle", "Youth", "Resilience".

myoscore_weights() — Dimension Weights

Returns the named numeric vector of dimension weights.

r
myoscore_weights()
#> Strength       Mass LeanMuscle      Youth Resilience
#>    0.252      0.177      0.243      0.242      0.087

myoscore_dimensions() — Dimension Names

r
myoscore_dimensions()
#> [1] "Strength"   "Mass"       "LeanMuscle" "Youth"      "Resilience"

myoscore_colors() — Color Palettes

r
# Five dimension colors
myoscore_colors("dimensions")
#>   Strength       Mass LeanMuscle      Youth Resilience
#>  "#50327b"  "#46508b"  "#f4e030"  "#72c95e"  "#31848f"

# Unhealthy-to-healthy spectrum
myoscore_colors("spectrum")
#> unhealthy      mild   neutral  positive   healthy
#> "#50327b" "#46508b" "#31848f" "#72c95e" "#f4e030"

Visualization

Radar Chart

Requires the fmsb package.

r
# install.packages("fmsb")

# Overall mean radar
myoscore_plot_radar(scores)

# Grouped by condition (faceted panels)
myoscore_plot_radar(scores, groups = metadata$condition)

# Overlaid on single chart
myoscore_plot_radar(scores, groups = metadata$condition, facet = FALSE)

# Single sample with per-dimension colored segments
myoscore_plot_radar(c(72.3, 65.1, 80.2, 55.8, 68.4), title = "Patient A")

Parameters:

ParameterDefaultDescription
scoresData.frame from myoscore_score(), or a named numeric vector of 5 values
groupsNULLFactor/character vector for group comparison
colorsautoColor vector (one per group)
facetTRUESeparate panel per group
titleNULLMain title
show_valuesTRUEShow score values at vertices

Grouped Boxplot

Uses ggplot2 if available, otherwise falls back to base R.

r
# install.packages("ggplot2")

# Compare MyoScore across groups
myoscore_plot_boxplot(scores, groups = metadata$condition)

# Plot all dimensions
myoscore_plot_boxplot(scores, groups = metadata$condition, which = "all")

# Single dimension
myoscore_plot_boxplot(scores, groups = metadata$condition, which = "Youth")

Parameters:

ParameterDefaultDescription
scoresData.frame from myoscore_score()
groupsFactor/character vector of group labels
which"MyoScore""MyoScore", any dimension name, or "all"
colorsautoColor vector
use_ggplotTRUEUse ggplot2 if available
titleNULLMain title

Built-in Data

myoscore_genes

A data.frame with 591 gene-dimension entries (417 unique genes) used in scoring.

r
data(myoscore_genes)
head(myoscore_genes)

# Genes per dimension
table(myoscore_genes$dimension)
ColumnDescription
IDGene symbol (HGNC)
weightGene weight from TWAS Z-scores
direction_v3+1 = high expression is healthy; -1 = high expression is unhealthy
dimensionOne of the five MyoScore dimensions

Dependencies

PackageTypePurpose
stats, utils, graphics, grDevicesRequiredBase R functionality
ggplot2 (>= 3.4.0)SuggestedEnhanced boxplots
fmsbSuggestedRadar charts
patchworkSuggestedMulti-panel layouts
testthat (>= 3.0.0)SuggestedUnit testing
knitr, rmarkdownSuggestedVignettes

Example Workflow

r
library(MyoScore)

# 1. Load and score
scores <- myoscore_score("my_cohort_counts.csv")

# 2. Attach metadata
metadata <- read.csv("my_cohort_metadata.csv")

# 3. Visualize
# Radar chart comparing disease vs control
myoscore_plot_radar(scores, groups = metadata$condition)

# Boxplot of all dimensions
myoscore_plot_boxplot(scores, groups = metadata$condition, which = "all")

# 4. Export results
results <- cbind(metadata, scores)
write.csv(results, "my_cohort_myoscores.csv", row.names = FALSE)

Citation

Revealing myopathy spectrum: integrating transcriptional and clinical features of human skeletal muscles with varying health conditions. Communications Biology, 2024. DOI: 10.1038/s42003-024-06096-7

Source Code

最近更新