Split table with resizing boxes

Does anyone have an idea what this chart looks like? It looks like a heat map . However, instead of using color, the size of each cell is used to indicate the value. I want to build such a figure, but I do not know how to implement it. Can this be done in R or Matlab? enter image description here

+5
source share
3 answers

Try the scatter:

scatter(x,y,sz,c,'s','filled'); 

where x and y are the positions of each square, sz is the size (must be a vector of the same length as x and y), and c is a 3x matrix of length (x) with a color value for each record. Labels for the chart can be entered using the set (gcf, properties) or xticklabels:

 X=30; Y=10; [x,y]=meshgrid(1:X,1:Y); x=reshape(x,[size(x,1)*size(x,2) 1]); y=reshape(y,[size(y,1)*size(y,2) 1]); sz=50; sz=sz*(1+rand(size(x))); c=[1*ones(length(x),1) repmat(rand(size(x)),[1 2])]; scatter(x,y,sz,c,'s','filled'); xlab={'ACC';'BLCA';etc} xticks(1:X) xticklabels(xlab) set(get(gca,'XLabel'),'Rotation',90); ylab={'RAPGEB6';etc} yticks(1:Y) yticklabels(ylab) 

EDIT: yticks and co are only available for> R2016b, if you do not have a newer version, you should use set instead:

 set(gca,'XTick',1:X,'XTickLabel',xlab,'XTickLabelRotation',90) %rotation only available for >R2014b set(gca,'YTick',1:Y,'YTickLabel',ylab) 

enter image description here

+3
source

In R , the corrplot package can be used. In particular, you should use method = 'square' when creating the graph.

Try this as an example:

 library(corrplot) corrplot(cor(mtcars), method = 'square', col = 'red') 

enter image description here

+2
source

in R, you should use ggplot2 , which allows you to map your values ​​(gene expression in your case?) to the size variable. Here I made a simulation that resembles your data structure:

 my_data <- matrix(rnorm(8*26,mean=0,sd=1), nrow=8, ncol=26, dimnames = list(paste0("gene",1:8), LETTERS)) 

Then you can process the data frame, which will be ready to visualize ggplot2 data:

 library(reshape) dat_m <- melt(my_data, varnames = c("gene", "cancer")) 

Now use ggplot2::geom_tile() to map the values ​​to the variable size . You can update additional plot features.

 library(ggplot2) ggplot(data=dat_m, aes(cancer, gene)) + geom_tile(aes(size=value, fill="red"), color="white") + scale_fill_discrete(guide=FALSE) + ##hide scale scale_size_continuous(guide=FALSE) ##hide another scale 

enter image description here

+2
source

Source: https://habr.com/ru/post/1264363/


All Articles