ByrumLab / proteoDA

GNU General Public License v3.0
12 stars 11 forks source link

Error in `combine_vars()`: #> ! Faceting variables must have at least one value #249

Open Gonzazsm97 opened 1 year ago

Gonzazsm97 commented 1 year ago

I keep getting an error message when executing the write_norm_report function. The error reads: "Error in combine_vars(): #> ! Faceting variables must have at least one value"

The code I am using looks as follows. I also included the first few lines of my datasets, if that helps.


#Load data
input_data <- read.csv("palm_dataset.csv")
sample_metadata <- read.csv("metadata.csv")

# Separate annotation from intensity data
intensity_data <- input_data[,5:13] # select columns 5 to 13
annotation_data <- input_data[,1:4] # select columns 1 to 4

rownames(sample_metadata) <- sample_metadata$data_column_name

raw <- DAList(data = intensity_data,
              annotation = annotation_data,
              metadata = sample_metadata,
              design = NULL,
              eBayes_fit = NULL,
              results = NULL,
              tags = NULL)
head(raw$data)
#>                     NC1      NC2     NC3      HX1      HX2      HX3       PA1
#>  TcYC6_0069830  9767900 11703000 9413000 27901000 20761000 22328000 118590000
#>  TcYC6_0054920        0        0       0        0        0        0  55961000
#>  TcYC6_0054930  4364600  4267900 4617400  5173000  4841500  4083400  55961000
#>  TcYC6_0093960        0   786260  689090        0        0   846780  54371000
#>  TcYC6_0012200  4954300  6039700 5045100 16711000 11933000 13351000  54596000
#>  TcYC6_0124770        0        0       0 14640000 13271000 10742000  53649000
#>                       PA2      PA3
#>  TcYC6_0069830  104480000 95515000
#>  TcYC6_0054920   68751000 47907000
#>  TcYC6_0054930   68751000 47907000
#>  TcYC6_0093960   59262000 48255000
#>  TcYC6_0012200   59694000 44196000
#>  TcYC6_0124770   49187000 49586000
head(raw$metadata)
#>     data_column_name sample batch  group
#> NC1              NC1    NC1     1 NegCon
#> NC2              NC2    NC2     1 NegCon
#> NC3              NC3    NC3     1 NegCon
#> HX1              HX1    HX1     1 Hydrox
#> HX2              HX2    HX2     1 Hydrox
#> HX3              HX3    HX3     1 Hydrox
head(raw$annotation)
#>                      uniprot_id
#>  TcYC6_0069830   TcYC6_0069830 
#>  TcYC6_0054920   TcYC6_0054920 
#>  TcYC6_0054930   TcYC6_0054930 
#>  TcYC6_0093960   TcYC6_0093960 
#>  TcYC6_0012200   TcYC6_0012200 
#>  TcYC6_0124770   TcYC6_0124770 
#>                                                                                        gene.product
#>  TcYC6_0069830                                               glycosomal membrane protein, putative 
#>  TcYC6_0054920                                            flagellar calcium-binding 24 kDa protein 
#>  TcYC6_0054930   Flagellar calcium-binding 24 kDa protein [Source:UniProtKB/TrEMBL;Acc:A0A2V2V7B0] 
#>  TcYC6_0093960          EF-hand domain-containing protein [Source:UniProtKB/TrEMBL;Acc:A0A2V2X784] 
#>  TcYC6_0012200       Putative glycosomal membrane protein [Source:UniProtKB/TrEMBL;Acc:A0A2V2XFQ9] 
#>  TcYC6_0124770                                                            Surface membrane protein 
#>                 protein.length Molecular.Weight
#>  TcYC6_0069830             244           27 kDa
#>  TcYC6_0054920             211           24 kDa
#>  TcYC6_0054930             211           24 kDa
#>  TcYC6_0093960             215           23 kDa
#>  TcYC6_0012200             218           24 kDa
#>  TcYC6_0124770             401           43 kDa

#Filter data           
filtered_samples <- zero_to_missing(raw)
filtered_proteins <- filter_proteins_by_group(filtered_samples,
                                               min_reps = 2,
                                               min_groups = 1,
                                               grouping_column = "group")
#> Keeping only protein entries with non-missing intensity in at least 2 samples
#> in at least 1 group
#> Filtered 90 entries from the dataset leaving 726 entries for analysis
head(filtered_proteins$data)
#>                     NC1      NC2     NC3      HX1      HX2      HX3       PA1
#>  TcYC6_0069830  9767900 11703000 9413000 27901000 20761000 22328000 118590000
#>  TcYC6_0054920       NA       NA      NA       NA       NA       NA  55961000
#>  TcYC6_0054930  4364600  4267900 4617400  5173000  4841500  4083400  55961000
#>  TcYC6_0093960       NA   786260  689090       NA       NA   846780  54371000
#>  TcYC6_0012200  4954300  6039700 5045100 16711000 11933000 13351000  54596000
#>  TcYC6_0124770       NA       NA      NA 14640000 13271000 10742000  53649000
#>                       PA2      PA3
#>  TcYC6_0069830  104480000 95515000
#>  TcYC6_0054920   68751000 47907000
#>  TcYC6_0054930   68751000 47907000
#>  TcYC6_0093960   59262000 48255000
#>  TcYC6_0012200   59694000 44196000
#>  TcYC6_0124770   49187000 49586000

#Normalization report
write_norm_report(filtered_proteins,
                  grouping_column = "group",
                  output_dir = "01_QC_report",
                  filename = "normalization.pdf",
                  overwrite = T,
                  suppress_zoom_legend = FALSE,
                  use_ggrastr = FALSE)
#> Starting normalizations
#> Normalizations finished
#> Saving report to: '01_QC_report/normalization.pdf'
#> Error in `combine_vars()`:
#> ! Faceting variables must have at least one value
#> Backtrace:
#>      ▆
#>   1. └─proteoDA::write_norm_report(...)
#>   2.   ├─ggplot2::ggsave(...)
#>   3.   │ ├─... %||% "transparent"
#>   4.   │ ├─ggplot2::calc_element("plot.background", plot_theme(plot))
#>   5.   │ └─ggplot2:::plot_theme(plot)
#>   6.   └─gridExtra::marrangeGrob(...)
#>   7.     ├─base::do.call(arrangeGrob, c(list(grobs = groups[[g]]), params))
#>   8.     └─gridExtra (local) `<fn>`(grobs = `<list>`, top = NA, layout_matrix = `<int[,1]>`)
#>   9.       └─base::lapply(grobs[toconv], ggplot2::ggplotGrob)
#>  10.         └─ggplot2 (local) FUN(X[[i]], ...)
#>  11.           ├─ggplot2::ggplot_gtable(ggplot_build(x))
#>  12.           │ └─ggplot2:::attach_plot_env(data$plot$plot_env)
#>  13.           │   └─base::options(ggplot2_plot_env = env)
#>  14.           ├─ggplot2::ggplot_build(x)
#>  15.           └─ggplot2:::ggplot_build.ggplot(x)
#>  16.             └─layout$setup(data, plot$data, plot$plot_env)
#>  17.               └─ggplot2 (local) setup(..., self = self)
#>  18.                 └─self$facet$compute_layout(data, self$facet_params)
#>  19.                   └─ggplot2 (local) compute_layout(..., self = self)
#>  20.                     └─ggplot2::combine_vars(data, params$plot_env, vars, drop = params$drop)
#>  21.                       └─cli::cli_abort("Faceting variables must have at least one value")
#>  22.                         └─rlang::abort(...)

Created on 2023-08-28 with reprex v2.0.2

jbird9 commented 1 year ago

Dear Gonzazsm97,

I was unable to replicate this error. However, this error points to issue with an internal function in ggplot2 that is used in faceting. The only element in this function that relies on faceting is the page2 graphs that facet based on normalization method. Because some of the normalization methods rely on dependencies, I would suggest going back and being sure that dependencies = TRUE is was selected in your initial install using devtools.

Gonzazsm97 commented 1 year ago

Thank you for answering so quickly, I did install dependencies, and I have been able to run the example data set, so I assume all necessary packages are installed. I will try to look into what could cause faceting issues in general. Maybe something in the data itself could be causing the error.

KR-15 commented 10 months ago

Dear Gonzazsm97,

I do not know if you solved your problem but I just have this issue and solved it. Be sure that all your uniprot_ids (that are used to make the facet plot of all normalization) do not have unauthorized characters/symbols. To be sure of that you can use the make.names() function of R to transform for instance "-" into "." or any other unauthorized symbols.

I hope it will help.

Best