#' Plot2DScatterPlot
#'
#' Plot2DScatterPlot displays a 2D scatter plot of specified markers using the hexbin package.
#' @param TreeMetaCl object generated by buildFSOMTree function
#' @param Title title of the 2D scatter plot
#' @param Marker1 marker to plot on the abscissa ("x")
#' @param Marker2 marker to plot on the ordinate ("y")
#' @param minct minimun count of cells to display as a polygon on the plot
#' @param style appareance of the polygons for the plot, that can be "colorscape","nestle.lattice", "nestle.centroids"...
#' @return PDF file of the chosen 2D scatter plot, that is saved in the working directory
#' @examples Plot2DScatterPlot(CytoTree,"Experiment 1","FSC-A","SSC-A",100,"colorscale")
#' @export
Plot2DScatterPlot<-function(TreeMetaCl,Title,Marker1,Marker2,mincnt,style){
library(hexbin)
ClustersData<-as.data.frame(TreeMetaCl$fSOMTree$map$mapping)
MarkersData<-as.data.frame(TreeMetaCl$fSOMTree$data)
PrettyNames<-as.data.frame(TreeMetaCl$fSOMTree$prettyColnames)
PrettyNames$UglyNames<-row.names(PrettyNames)
names(PrettyNames)[1]<-"PrettyNames"
colnames(MarkersData)<-PrettyNames$PrettyNames[match(colnames(MarkersData),PrettyNames$UglyNames)]
FrameMarkers<-cbind(ClustersData,MarkersData)
names(FrameMarkers)[1]<-"Clusters"
MetaclFrame<-as.data.frame(TreeMetaCl$metaClNumber)
MetaclFrame$Clusters<-c(1:nrow(MetaclFrame))
names(MetaclFrame)[1]<-"Metaclusters"
FrameMarkers$Metaclusters<-MetaclFrame[match(x=FrameMarkers$Clusters, table = MetaclFrame$Clusters),"Metaclusters"]
x=FrameMarkers[[Marker1]]
y=FrameMarkers[[Marker2]]
bin=hexbin(x,y)
pdf(file=NoSpCharForFile(paste(Title)),"2D_Scatterplot.jpeg")
gplot.hexbin(bin,style,xlab = Marker1 ,ylab = Marker2 ,legend = 0.7,lcex = 0.5,mincnt,
clip = "on",minarea = 0.005,maxarea = 1)
dev.off()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.