# Subset example data
db <- subset(InfluenzaDb, CPRIMER %in% c("IGHA","IGHM") &
BARCODE %in% c("RL016","RL018","RL019","RL021"))
# Calculate BASELINe
# By default, calcBaseline collapses the sequences in the db by the column "CLONE",
# calculates the numbers of observed mutations and expected frequencies of mutations,
# as defined in the IMGT_V_NO_CDR3 and using the HS5FModel targeting model.
# Then, it calculates the BASELINe posterior probability density functions (PDFs) for
# sequences in the updated db files; using the focused test statistic
db_baseline <- calcBaseline(db,
sequenceColumn="SEQUENCE_IMGT",
germlineColumn="GERMLINE_IMGT_D_MASK",
testStatistic="focused",
regionDefinition=IMGT_V_NO_CDR3,
targetingModel = HS5FModel,
nproc = 1)
# Grouping the PDFs by the BARCODE and CPRIMER columns in the db, corresponding
# respectively to sample barcodes and the constant region isotype primers.
baseline <- groupBaseline(db_baseline, groupBy=c("BARCODE", "CPRIMER"))
# Plot mean and confidence interval
plotBaselineSummary(baseline, "BARCODE", "CPRIMER", style="mean")
plotBaselineSummary(baseline, "BARCODE", "CPRIMER", subsetRegions="CDR", style="mean")
plotBaselineSummary(baseline, "BARCODE", "CPRIMER", facetBy="group", style="mean")
# Reorder and recolor groups
group_colors <- c("IGHM"="darkorchid", "IGHA"="steelblue")
plotBaselineSummary(baseline, "BARCODE", "CPRIMER", groupColors=group_colors, style="mean")
# Plot subset of data
stats <- subset(getBaselineStats(baseline), BARCODE %in% c("RL018", "RL019"))
plotBaselineSummary(stats, "BARCODE", "CPRIMER", groupColors=group_colors, style="mean")
Run the code above in your browser using DataLab