# TODO: Add comment # # Author: E.Korsching 9.12.2011, 10-2021 ############################################################################### plot.sample.search.dependencies.2 <- function(x, raw=NULL, ref.size.range=c(1,4), ylim=NULL, y.at=NULL, ylab="correlation", text=T, description="", cex=0.8, mfrow=c(1,1), sym.norm=0.125, test.meta=F, ssqflag=1) { # draw : superimpose two regression plots (2 list element) and show expression strength # with the same marker panel in the reference and test set (test might be differ in size) # (avoid special characters in col names) # using results from enumeration.search.dep.boots.f90 to fill cor table, order vec (example at the end) # input : x: list containing a list with: 1. cor table, 2. order vec, 3. plot color : # list(list(cor 1, order 1, color 1), list(cor 2, order 2, color 2)) # raw: list with one or two raw data matrix (with column names identical to the cor table names) for superimposing average expression values # ref.size.range: min max values of expression range -- check if appropriate -- # ylim: y axis range: c(min,max) given or generated from the data, y.at: tick positions, ylab: y label # text: print data name and global ssq (T/F) and if given a description in next line # cex: text size, mfrow: layout of plot page (rows,cols) # test.meta: T: only give meta data structure back # sym.norm: needs adjustment if small test set, circle symbol size for expression values: scaling factor # (! both experiments need to have the same scale) # radius is given: 0.25 is maximum radius, raw size is 1..4, because area is quadratic, sqrt on expr. values 1..2 : -> /8 #ini if(missing(x)){ cat("\n correlation matrix, order vector and color must be provided"); break } len.list <- length(x) if(len.list<1 | len.list>2){ cat("\n list needs one or two list objects"); break } # source source(file="../0functions/0general/barplot.ek.R") # cex scaling cex.s <- 0.3 # create meta data list structure (not ordered) metadata <- vector("list", len.list) for(j in 1:len.list){ metadata[[j]] <- vector("list", 6) names(metadata[[j]]) <- c("nr.test","nc.ref","no.rnames","no.cnames","mean.test","mean.ref") } # no: not ordered (all) tmp.r <- c(0,0) # start value for range for(j in 1:len.list){ tmp <- x[[j]] len.element.list <- length(tmp) if(len.element.list!=3){ cat("\n internal list element ",j," must contain on the\n first position a cor table, on the second a order object and on the third a color"); break } #create max range tmp.r1 <- range(x[[j]][[1]])[1] tmp.r2 <- range(x[[j]][[1]])[2] if( tmp.r[1]>tmp.r1 ){ tmp.r[1] <- tmp.r1 } if( tmp.r[2]35){ tmp <- paste(substr(tmp, start=1, stop=35), ".. ") } #restrict length of name to 35 if(description!=""){ text(x=1, y=1.3, labels=description, adj=0, cex=cex+cex.s) }else{ text(x=1, y=1.3, labels=tmp, adj=0, cex=cex+cex.s) } if(len.list==1){ text(x=1, y=0.3, labels=paste("ssqg=",ssqg[1]), col=x[[1]][[3]], adj=0, cex=cex+cex.s) }else{ text(x=1.1, y=0.24, labels=paste("ssqg=",ssqg[1]), col=x[[1]][[3]], adj=0, cex=cex+cex.s) text(x=3, y=0.3, labels=paste("/ ",ssqg[2]), col=x[[2]][[3]], adj=0, cex=cex+cex.s) } } } } cat("\n min. global ssq = ", paste(ssqg, sep=", "), "\n") par(mar=c(5,4,4,2)) #default mar return() } ##two #pdf(file=paste(getwd(),"/results/robert/test",".",format(Sys.time(), "%Y%m%d%H%M"),".pdf", sep=""), # width=11, height=7, onefile=T, title="MBC.perm.lumi2", pointsize=12) #plot.sample.search.dependencies.2(x=list( # list(rk.Rmale.2.d.1h[[3]][1:9,,drop=F], rk.Rmale.2.d.1h[[1]][1,2:10], "black"), # list(rk.Hfemale.c2.d.1j[[3]][1:9,,drop=F], o=rk.Hfemale.c2.d.1j[[1]][1,2:10], "blue") # ), # raw=list(Rmale.2.d, Hfemale.c2.d), ref.size.range=c(1,4), # ylim=NULL, y.at=NULL, ylab="correlation", text=T, description="1h - MBC, 1j - FBC", cex=0.8, mfrow=c(2,3), ssqflag=1 ) # #plot.sample.search.dependencies.2(x=list( # list(rk.Rmale.2.d.1i[[3]][1:7,,drop=F], o=rk.Rmale.2.d.1i[[1]][1,2:8], "black"), # list(rk.Hfemale.c2.d.1k[[3]][1:7,,drop=F], o=rk.Hfemale.c2.d.1k[[1]][1,2:8], "red") # ), # raw=NULL, ref.size.range=c(1,4), # ylim=c(-0.4,0.4), y.at=NULL, ylab="correlation", text=T, description="1i - MBC, 1k - FBC", cex=0.8, mfrow=c(2,3), ssqflag=1 ) #dev.off()