Update:
I can install and use the circlize library in JupyterLab R console. But when I tried to do the same in JupyterLab SAS console, I got errors.
WARNING: R: Warning in install.packages("circlize") :
WARNING: R: 'lib = "/opt/sas/viya/home/sas-pyconfig/R-4.2.2.1717422377/lib64/R/library"' is not writable
ERROR: R: Error in askYesNo(gettext("Would you like to use a personal library instead?"), :
ERROR: R: Unrecognized response “library(circlize)”
Output from JupyterLab R console:
Codes in JupyterLab SAS console:
proc iml;
submit / R;
Sys.setenv(R_LIBS_USER="/opt/conda/lib/R/library")
install.packages("circlize")
library(circlize)
# Input matrix
values <- c(
1,0,0,2,0,
1,0,1,1,0,
1,0,0,0,0,
1,0,0,0,0,
4,0,3,4,0,
7,2,4,10,0,
2,0,0,0,0,
1,0,1,1,1,
1,0,0,0,0,
7,0,10,15,0,
0,0,0,1,0,
1,0,0,0,0,
1,0,0,1,0,
4,0,1,6,0,
4,0,0,4,0,
1,0,0,1,0,
1,0,0,2,0,
0,0,0,1,0,
1,0,0,2,0,
11,1,36,33,6
)
matrix <- matrix(values, 5, 20)
# Labeling
rownames(matrix) <- c("Age 65 to 80", "Over 80", "Age 30 to 50", "Age 50 to 65", "Less than 30") # Label the row categories
colnames(matrix) <- c("Atrial fibrillation", "AF, DM", "AF, DM, HF", "AF, DM, HF, HTN", "AF, HF", "AF, HF, HTN", "AF, HF, Stroke", "AF, HTN",
"AF, HTN, Stroke", "AF, Stroke", "Diabetes", "DM, HF, HTN", "DM, HTN", "DM, HTN, Stroke", "Heart failure", "HF, HTN", "Hypertension",
"HTN, Stroke", "No comorbidity", "Stroke") # Label the column categories
# Define colors
colors <- c("Over 80" = "Red", "Age 50 to 65" = "#008000", "Age 30 to 50" = "Orange", "Age 65 to 80" = "#ffef00", "Less 30" = "#2a52be", "No comorbidity" = "black", "Atrial fibrillation" = "#ff0800", "Diabetes" = "#a52a2a", "Hypertension" = "#ffbcd9")
# Generate the chord diagram
# chordDiagram(matrix, transparency = 0.6, annotationTrack = c("axis", "grid")) # Make the chord diagram
circos.par(canvas.xlim = c(-0.80, 0.80), canvas.ylim = c(-0.80, 0.80))
chordDiagram(matrix, grid.col = colors, scale = FALSE, annotationTrack = c("grid", "axis"),
preAllocateTracks = list(track.height = max(strwidth(unlist(dimnames(matrix))))))
circos.track(track.index = 1, panel.fun = function(x, y) {
circos.text(CELL_META$xcenter, CELL_META$ylim[1], CELL_META$sector.index,
facing = "clockwise", niceFacing = TRUE, adj = c(-0.30, 0), cex = 0.50)
}, bg.border = NA) # here set bg.border to NA is important
title(main = "Figure 1 Relationship between age categories and comorbidities", font.main = 1)
endsubmit;
quit;
... View more