Re: help with error message - very new to ggplot2

53 views
Skip to first unread message

Ben Bond-Lamberty

unread,
Apr 18, 2014, 5:54:16 AM4/18/14
to ggplot2
It looks like your first error is a file
(ko_metagenome_contributions_forR.tab) not found. This is not an error
that anyone on this list can help you with; make sure the script
you're using can find all its necessary inputs. Note that generally
people on this listserv will be much more likely to try to help if (i)
you provide a reproducible example and (ii) show that you've tried to
solve the problem yourself.

More generally, I'd suggest taking time to learn some R basics if
you're going to use an R script.

Regards
Ben

On Thu, Apr 17, 2014 at 1:14 PM, TEXAG <bguar...@gmail.com> wrote:
> I would greatly appreciate the help and I'm a total newbie. Here is my
> complete workflow... the error is at the bottom. I would very much
> appreciate a very complete answer as I really have no clue what I'm doing,
> it would be great to get this plot generated though... Thanks!
>
> #!/usr/bin/env Rscript
>>
>> #USAGE:
>> #./plot_metagenome_contributions.R <input file from picrust> <output pdf
>> file> <function> <taxa rank>
>> #
>> #For example:
>> #./plot_metagenome_contributions.R metagenome_contributions.tab
>> K00001_family.pdf K00001 Family
>> #OR
>> #./plot_metagenome_contributions.R metagenome_contributions.tab
>> K00001_phylum.pdf K00001 Phylum
>> #
>> #Choices for taxa are:
>> "Phylum",'Class','Order','Family','Genus','Species','OTU'
>>
>> library(ggplot2)
>> Args <- commandArgs(TRUE)
>>
>> input_file<-Args[1]
>> input_file<-Args[ko_metagenome_contributions_forR.tab]
> Error: object 'ko_metagenome_contributions_forR.tab' not found
>> input_file<-Args["ko_metagenome_contributions_forR.tab"]
>> output_file<-Args["K03406_family"]
>> function_id<-Args[K03406]
> Error: object 'K03406' not found
>> function_id<-Args["K03406"]
>> taxa_rank<-Args['Family']
>>
>> #read in the file created by PICRUSt's metagenome_contributions.py
>> d<-read.delim(input_file)
> Error in file(file, "rt") : cannot open the connection
> In addition: Warning message:
> In file(file, "rt") : cannot open file 'NA': No such file or directory
>> d<-read.delim(input_file)
> Warning messages:
> 1: In scan(file, what, nmax, sep, dec, quote, skip, nlines, na.strings, :
> EOF within quoted string
> 2: In scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
> embedded nul(s) found in input
>>
>> #Pull out only one gene for plotting
>> d<-d[d$Gene == function_id,]
>>
>> #Filter out OTUs that only contribute a small amount of functions (e.g. 1
>> or less)
>> #Increase this number if too many taxa labels are showing up in the
>> legend.
>> otu_contribution_cut_off<-0 #0 means no filter being applied
>> d<-d[d$CountContributedByOTU > otu_contribution_cut_off,]
> Error in d$CountContributedByOTU :
> $ operator is invalid for atomic vectors
>>
>> #output image to pdf (this can be change to png, svg, etc)
>> pdf(output_file)
>>
>> #create stacked bar chart, with x-axis being samples, collapsing to user
>> defined taxonomic rank, and weighted by actual OTU abundances
>> qplot(factor(Sample), data=d,
>> geom="bar",fill=factor(d[,taxa_rank]),weight=CountContributedByOTU,
>> xlab="Samples", ylab=paste("Abundance of ",function_id)) +
> +
> + #legend title
> + scale_fill_discrete(taxa_rank) +
> +
> + #rotate x axis labels
> + theme(axis.text.x=element_text(angle = 90, vjust = 0.5))
> Error: ggplot2 doesn't know how to deal with data of class factor
>>
>> graphics.off()
>> data = data.frame()
>>
>> #create stacked bar chart, with x-axis being samples, collapsing to user
>> defined taxonomic rank, and weighted by actual OTU abundances
>> qplot(factor(Sample), data=d,
>> geom="bar",fill=factor(d[,taxa_rank]),weight=CountContributedByOTU,
>> xlab="Samples", ylab=paste("Abundance of ",function_id)) +
> +
> + #legend title
> + scale_fill_discrete(taxa_rank) +
> +
> + #rotate x axis labels
> + theme(axis.text.x=element_text(angle = 90, vjust = 0.5))
> Error: ggplot2 doesn't know how to deal with data of class factor
>
>
> --
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ggplot2+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages