I don't understand what you mean.
So, you can create a new vector that contains expression
s using the plotmath formulation.
Instead of "(NO3-)", you can write expression(NO[3]^"-")
, instead of "(NH4+)" you can write NH[4]^"+"
etc. Then you can pass it as the labels_col =
argument of pheatmap()
to overwrite the original labels.
Similarly, you can replace the column labels with the argument labels_row =
, using expression(italic(Bradyrhizobium))
etc.
To computationally recode the row labels (without retyping by hand), this should work (note, this is advanced R, it's hard to understand why it works):
new_row_labels <- paste0("italic(", colnames(rmt), ")")
new_row_labels <- as.expression(sapply(new_row_labels, str2lang))
I can't think of any easy way to computationally create the column labels, as R can't guess where you want the subscripts and superscripts, I think you have to retype it yourself. Once you have created these vectors new_row_labels
and new_col_labels
, you can pass them in your pheatmap()
call, something like that:
pheatmap(rmt,
labels_row = new_row_labels, labels_col = new_col_labels,
cluster_rows = F, cluster_cols = F,
display_numbers = pmt,fontsize_number = 12,
number_color = "black", cellwidth = 20,
cellheight = 20,color = mycol)
I can't directly give you the code for your data, as I don't have the original datasets, you didn't give us a reproducible example.