About expressionBarplot () in cummeRbund
1
0
Entering edit mode
9.8 years ago
Ginsea Chen ▴ 130

Hi

I tried to use R to analysis the results of cufflinks, but R gave me some errors, I don't know how to solve them. So, I'm pasting the commands below:

> cuff<- readCufflinks('diff_out')
> csDensity(genes(cuff))
Warning messages:
1: Removed 77219 rows containing non-finite values (stat_density). 
2: Removed 34180 rows containing non-finite values (stat_density). 
3: In grid.Call.graphics(L_polygon, x$x, x$y, index) :
  semi-transparency is not supported on this device: reported only once per page
> mygene<- getGene(cuff,'AT3G26280')
> expressionBarplot(mygene)
Error : Mapping a variable to y and also using stat="bin".
  With stat="bin", it will attempt to set the y value to the count of cases in each group.
  This can result in unexpected behavior and will not be allowed in a future version of ggplot2.
  If you want y to represent counts of cases, use stat="bin" and don't map a variable to y.
  If you want y to represent values in the data, use stat="identity".
  See ?geom_bar for examples. (Defunct; last used in version 0.9.2)

Please tell me how to solve this error.

Best regards

error R expressionBarplot RNA-Seq • 4.6k views
ADD COMMENT
0
Entering edit mode

expressionBarplot() is a cummeRbund function. I'll edit your post accordingly.

ADD REPLY
5
Entering edit mode
9.8 years ago

It looks like this is just a bug in cummeRbund (rather, it just hasn't been updated to match the current version of ggplot2). You might post this to the bioconductor email list and CC the package maintainer. The fix is actually really simple (it's just changing one line).

For what it's worth, a slightly modified version of that function is below. It'll probably work (but please do notify the package maintainer in any case). Note that I've changed the case of the function name to not mask the original.

expressionbarplot<-function(object,logMode=FALSE,pseudocount=1.0,showErrorbars=TRUE,showStatus=TRUE,replicates=FALSE,...){
        quant_types<-c("OK","FAIL","LOWDATA","HIDATA","TOOSHORT")
        quant_types<-factor(quant_types,levels=quant_types)
        quant_colors<-c("black","red","blue","orange","green")
        names(quant_colors)<-quant_types

        dat<-fpkm(object)
        if(replicates){
                repDat<-repFpkm(object)
                colnames(repDat)[1]<-"tracking_id"
        }
        #TODO: Test dat to ensure that there are >0 rows to plot.  If not, trap error and move on...

        colnames(dat)[1]<-"tracking_id"

        if(logMode)
        {
            dat$fpkm <- dat$fpkm + pseudocount
            dat$conf_hi <- dat$conf_hi + pseudocount
            dat$conf_lo <- dat$conf_lo + pseudocount

                if(replicates){
                        repDat$fpkm<-repDat$fpkm + pseudocount
                }
    }

    p<-ggplot(dat,aes(x=sample_name,y=fpkm,fill=sample_name))

        p <- p + geom_bar(stat="identity")

        if(replicates){
                p <- p + geom_point(aes(x=sample_name,y=fpkm),size=3,shape=18,colour="black",data=repDat)
        }

        if (showErrorbars)
        {
            p <- p +
                    geom_errorbar(aes(ymin=conf_lo,ymax=conf_hi,group=1),width=0.5)
        }

        if (logMode)
        {
            p <- p + scale_y_log10()
    }

    p <- p + facet_wrap('tracking_id') +
          labs(title=object@annotation$gene_short_name)+theme(axis.text.x=element_text(hjust=0,angle=-90))

    if (logMode)
    {
        p <- p + ylab(paste("FPKM +",pseudocount))
    } else {
        p <- p + ylab("FPKM")
    }

        if (showStatus){
                if(logMode){
                        p<-p+geom_text(aes(x=sample_name,y=1,label=quant_status,color=quant_status),vjust=1.5,size=3)

                }else{
                        p<-p+geom_text(aes(x=sample_name,y=0,label=quant_status,color=quant_status),vjust=1.5,size=3)
                }
        }

        p <- p + theme(legend.position="none")

        #Default cummeRbund colorscheme
        p<-p + scale_fill_hue(l=50,h.start=200)

        #Recolor quant flags
        p<- p+ scale_colour_manual(name='quant_status',values=quant_colors)

        p
}
ADD COMMENT
0
Entering edit mode

Wow, detailed answer, I am a new user of R, Thanks for your help. Now I will try to solve it as your follows.

ADD REPLY
0
Entering edit mode

This is very helpful!

ADD REPLY
0
Entering edit mode

Thanks for the workaround! Three months on and this still isn't fixed in the cummeRbund release.

VERY FRUSTRATING!!

o.o

ADD REPLY
0
Entering edit mode

I'll have to see if the OP ever reported this issue. If not, I'll do it and provide a link to this thread.

ADD REPLY
0
Entering edit mode

This should have been fixed in version 2.7.1, which will be the next release and should be out pretty soon (around the October 14th).

ADD REPLY

Login before adding your answer.

Traffic: 2440 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6