Skip to content

star graph

A star graph is similar to a pie chart, but each segment can have different radius. Below is a simple star graph drawn using general plotting functions in R. In this star graph, different asthma-related phenotypes are visualized per asthma class.

### Not to run ###

# characteristics of each class
astlc <- readRDS('results/asthma_LCA_nclass4.rds')
astlc$probs
$attack
                  0          1
class 1:  0.4137298 0.58627023
class 2:  0.7064193 0.29358072
class 3:  0.9490438 0.05095621
class 4:  0.9587120 0.04128805

$med
                  0          1
class 1:  0.4378314 0.56216863
class 2:  0.6177225 0.38227748
class 3:  0.9426313 0.05736868
class 4:  0.9265823 0.07341767

$astscore_cat
                   0          1            2
class 1:  0.01579295 0.02149644 9.627106e-01
class 2:  0.15562859 0.84437141 1.821109e-59
class 3:  0.80069044 0.19204350 7.266059e-03
class 4:  0.90750155 0.09249845 0.000000e+00

$repscore_cat
                   0          1          2
class 1:  0.06880375 0.35960778 0.57158847
class 2:  0.19922461 0.72065015 0.08012524
class 3:  0.93002137 0.05462077 0.01535786
class 4:  0.88213887 0.10612918 0.01173195

$psta_s1
                     0          1
class 1:  5.512196e-01 0.44878036
class 2:  5.178866e-01 0.48211336
class 3:  9.884459e-38 1.00000000
class 4:  9.279457e-01 0.07205428

$nasal_cum_s3
                  0         1
class 1:  0.3544853 0.6455147
class 2:  0.3904341 0.6095659
class 3:  0.1449373 0.8550627
class 4:  0.6856022 0.3143978

$adult_onset_comb
                  0         1
class 1:  0.2479621 0.7520379
class 2:  0.3315971 0.6684029
class 3:  0.4825311 0.5174689
class 4:  0.4283462 0.5716538
### Not to run ###

# star graph
png(file = 'results/astlc_stargraph.png', width = 1600, height = 800, res = 200)
probs <- data.frame(attack = astlc$probs$attack[, 2],
                    med = astlc$probs$med[, 2],
                    astscore.1or2 = astlc$probs$astscore_cat[, 2],
                    astscore.3to5 = astlc$probs$astscore_cat[, 3],
                    repscore.1or2 = astlc$probs$repscore_cat[, 2],
                    repscore.3to5 = astlc$probs$repscore_cat[, 3],
                    psta = astlc$probs$psta_s1[, 2],
                    nasal = astlc$probs$nasal_cum_s3[, 2],
                    adult = astlc$probs$adult_onset_comb[, 2])
probs <- rbind(probs, NA)
colors <- c('darkred', 'darkorange', 'skyblue1', 'skyblue4', 'deeppink1', 'deeppink4',
            'darkgreen', 'darkseagreen', 'darkgoldenrod')
stars(probs, nrow = 1, ncol = 5, labels = c(paste('class', 1:4), ''), scale = FALSE,
      draw.segments = TRUE, col.segments = colors, cex = 1.3)
legend('right', bty = 'n', col = colors, legend = colnames(probs), pch = 19)
dev.off()