如何从该绘图图中删除分层线和图例

时间:2020-10-02 02:55:22

标签: r plot

我正在使用来自edgeR包的名为maplot的函数。我认为该程序包基于先天绘图功能。这是我最终得到的情节。

enter image description here

我的问题是,如果要删除图例和lpot中的行,应在函数中包括什么参数?

1 个答案:

答案 0 :(得分:0)

我没有任何数据可用于测试,但这可能有用:

maPlot_modified <- function(x,y, logAbundance=NULL, logFC=NULL, normalize=FALSE, plot.it=TRUE, smearWidth=1, col=NULL, allCol="black", lowCol="orange", deCol="red", de.tags=NULL, smooth.scatter=FALSE, lowess=FALSE, ...)
#  Low-level function for creating an MA-plot for DGE data.
#  Created by Mark Robinson. Last modified by Davis McCarthy, 19 November 2010.
#  Edits by Gordon Smyth 20 March 2011.
{
    if( !is.null(logAbundance) && !is.null(logFC) ) {
        A <- logAbundance
        M <- logFC
        w <- v <- rep(FALSE, length(A))
        w <- A < -25+log2(1e6) # logCPM instead of logConc
        if( any(w) ) {
            shift <- max(abs(M[w])) - max(abs(M[!w]))
            A[w] <- min(A[!w]) - runif(sum(w),min=0,max=smearWidth)
            M[w] <- sign(M[w]) * (abs(M[w]) - shift)
        }
        
    } else {
        if(normalize) {
            x <- x/sum(x)
            y <- y/sum(y)
        }
        A <- (log2(x)+log2(y))/2
        M <- log2(y) - log2(x)
        w <- x==min(x) | y==min(y)
        if( any(w) ) {
            A[w] <- min(A[!w]) - runif(sum(w),min=0,max=smearWidth)
            M[w] <- log2(y[w]+min(y[!w])) - log2(x[w]+min(x[!w]))
        }
    }
    qs <- quantile(M, c(0.05,0.95))
    range <- qs[2]-qs[1]
    v <- (M < (median(M) - 5*range)) | (M > (median(M) + 5*range))
    if( any(v) ) {
        M[v] <- sign(M[v]) * (max(abs(M[!v])) + 0.5*range)
    }
    if(plot.it) {
        if( is.null(col) ) {
        col <- rep(allCol, length(A))
        if( any(w) | any(v) )
            col[w | v] <- lowCol
        }
        if(smooth.scatter) {
            smoothScatter(A, M, col=col, ...)
            grid()
            if( any(w) | any(v) )
                points(A[w | v], M[w | v], col=lowCol, ...)
        }
        else
            plot(A,M,col=col,...)
        points(A[de.tags],M[de.tags],col=deCol,...)
        }
    }
    invisible(list(A=A,M=M,w=w,v=v))
}

maPlot_modified(swirl[,3], main="MA plot without the stratified legend / lines")