假設(shè)有reader1 和reader2,分別對(duì)一定數(shù)量病人的某一影像指標(biāo)進(jìn)行評(píng)分,現(xiàn)在想看一下這兩位研究者評(píng)分的一致性,繪制Bland-Altman圖是一種較為直觀、簡單的方式。代碼實(shí)現(xiàn)方法如下:
- 顯示分組信息的B-A plot
library(BlandAltmanLeh)
library(ggplot2)
reader1 <- ap_reader1$Elongation # numeric
reader2 <- ap_reader2$Elongation
# bland.altman.plot(reader1, reader2) #普通B-A plot
MVI <- rep(c(1,2), 63, length.out = 125) # new knowledge; "each = 63"
ba.stats <- bland.altman.stats(reader1, reader2)
plot(ba.stats$means, ba.stats$diffs, col= MVI,
sub=paste("critical difference is", round(ba.stats$critical.diff,4)),
main="Bland-Altman Plot", ylim=c(-0.6,0.6), pch=18-MVI)
abline(h = ba.stats$lines, lty=c(2,3,2), col=c("lightblue","blue","lightblue"),
lwd=c(3,2,3))
legend(x = "topright", legend = c("MVI-","MVI+"), fill = 1:2) # 這里的fill和MVI里的值對(duì)應(yīng)
# Notes: MVI里賦值時(shí)不要賦0和1,因?yàn)樗麄兇砗诤桶?,圖片上顯示不出來

B-A plot_1.png
- 帶直方圖的B-A plot:
library(ggExtra)
print(ggMarginal(bland.altman.plot(reader1, reader2, graph.sys = "ggplot2"),
type = "histogram", size=4))

B-A plot_2.png
臨床上還會(huì)有一種情況,比如一個(gè)量表只有1-10分,2個(gè)評(píng)價(jià)者對(duì)100個(gè)患者評(píng)分的話,必然很多人的評(píng)分是相同的。如果用普通的B-A圖展示的話,有些點(diǎn)就會(huì)被覆蓋住,無法展現(xiàn)評(píng)分差異的全貌。以下代碼就是解決這種情況的:
- B-A圖里的重復(fù)值
A <- c(7, 8, 4, 6, 4, 5, 9, 7, 5, 8, 1, 4, 5, 7, 3, 4, 4, 9, 3, 3,
1, 4, 5, 6, 4, 7, 4, 7, 7, 5, 4, 6, 3, 4, 6, 4, 7, 4, 6, 5, 1, 1, 1, 1, 1, 1)
B <- c(8, 7, 4, 6, 3, 6, 9, 8, 4, 9, 0, 5, 5, 9, 3, 5, 5, 8, 3, 3,
1, 4, 4, 7, 4, 8, 3, 7, 7, 5, 6, 7, 3, 3, 7, 3, 6, 5, 9, 5, 1, 1, 1, 1, 1, 1)
bland.altman.plot(A, B)

B-A plot_3.png
bland.altman.plot(A, B, sunflower=TRUE) # 不同形狀代表不同的重復(fù)值

B-A plot_4.png
- ggplot2 給出的解決方案:
print( bland.altman.plot(A, B, graph.sys = "ggplot2", geom_count = TRUE) )

B-A plot_5.png
參考資料:
BlandAltmanLeh Intro