Can't color tips and nodes by trait
Issue #2
resolved
Dear Immcantation Team,
I’m trying to color the trees by a C gene call. Here’s how the trees were built:
dowser_clones <- all_clones |>
filter(sample_name == 'sample1') |>
formatClones(
traits = c('c_call_simplified'),
num_fields = c('duplicate_count'),
columns = c('sample_name'),
nproc = 4
)
custom_palette = getPalette(c(ISOTYPE_LEVELS, 'Germline'), 'Paired')
trees <- dowser_clones |>
getTrees(
build = 'dnapars',
id = sample(1:10e10, 1),
exec = '~/bin/phylip-3.697/exe/dnapars',
trait = 'c_call_simplified',
#palette = custom_palette,
nproc = 4
)
plots <- plotTrees(
trees[1:10,],
tips = 'c_call_simplified',
tip_palette = custom_palette,
tipsize = 'duplicate_count'
)
all_clones
is a data frame in AIRR format with a column called c_call_simplified
that has the C gene call.
I get the following error:
Error in plotTrees(trees[1:10, ], tips = "c_call_simplified", tip_palette = custom_palette, : 1 not found in tip_palette2 not found in tip_palette4 not found in tip_palette6 not found in tip_palette3 not found in tip_palette8 not found in tip_palette5 not found in tip_palette7 not found in tip_palette
Traceback:
1. plotTrees(trees[1:10, ], tips = "c_call_simplified", tip_palette = custom_palette,
. tipsize = "duplicate_count")
2. stop(paste(nfound, "not found in tip_palette"))
custom_palette
is:
IGHM'#A6CEE3'IGHD'#1F78B4'IGHG3'#B2DF8A'IGHG1'#33A02C'IGHA1'#FB9A99'IGHG2'#E31A1C'IGHG4'#FDBF6F'IGHE'#FF7F00'IGHA2'#CAB2D6'Germline'#6A3D9A'
When I replace custom_palette
with simply 'Paired'
I get a tree where all tips are of the same color:
Would appreciate any tips suggestions.
Comments (2)
-
-
- changed status to resolved
Appears to have been resolved. Please re-open if not.
- Log in to comment
Hey sorry for the slow reply. Is c_call_simplified stored as a factor? Seems like it’s using integers rather than strings as states for some reason. If so it’s best to convert it to a character before formatting the clones. Also, if you’re using ape 5.5, it’s best to update to the latest version, since we’ve had issues with 5.5 recently.