makeGraphDf - Build a data.frame from a ChangeoClone and an igraph object containing a clonal lineage


makeGraphDf creates a data.frame from a ChangeoClone and an igraph graph object containing a B cell lineage tree and associated sequence data. The data.frame contains the original fields and additions such as each sequence’s parent in the lineage tree, the lineage germline, and additional rows for inferred sequences.


objSeqId = "sequence_id",
objSeq = "sequence"


an igraph graph object for the lineage tree generated by buildPhylipLineage. Note that the field containing the nucleotide sequence in the object must be named sequence.
ChangeoClone object used to generate the lineage.
name of the sequence identifier field in curCloneObj.
name of the nucleotide sequence field in curCloneObj.


A data.frame with sequence and lineage information, including the the parent nucleotide sequence in the lineage tree(parent_sequence), an internal parent identifier (parent), and additional rows for germline sequence and inferred intermediate sequences.

Values in the sequence_id field are renamed to numeric values, prefixed with the clonal grouping identifier and labeled as either "Inferred" or "Germline" if they are not an observed sequence. For example, for a lineage with clone_id = 34 the new identifiers would be of the form: "34_Germline", "34_Inferred1", "34_1", "34_2", etc.

Note that the original sequence identifier is preserved in the orig_sequence_id field and the original parent sequence identifier is retained in orig_parent.


# Load and subset example data
data(ExampleDb, package = "alakazam")
data(ExampleTrees, package = "alakazam")
graph <- ExampleTrees[[17]]
db <- subset(ExampleDb, clone_id == graph$clone)
clone <- alakazam::makeChangeoClone(db)

# Extend data with lineage information
df <- makeGraphDf(graph, clone)

See also

See observedMutations to calculate mutation frequencies using parent_sequence as the reference germline. See ChangeoClone, buildPhylipLineage, and graph for details on the input objects.