brianstock / MixSIAR

A framework for Bayesian mixing models in R:
http://brianstock.github.io/MixSIAR/
94 stars 75 forks source link

Error loading discrimination data #177

Closed EllenMcKee closed 5 years ago

EllenMcKee commented 5 years ago

Hi Brian, When clicking 'Make Isospace plot' in the GUI, I get this error message:

Error in plot_data(gWidgets::svalue(mixsiar$plot_filename), gWidgets::svalue(mixsiar$plot_save_pdf), : *** Error: Source names do not match in source and discr data files. Please check your source and discr data file row names.

Both my source file and discrimination file have rows named horse, sheep, goat, rabbit or hare and nothing else. Do you know what could be going wrong here?

brianstock commented 5 years ago

Hi Ellen,

Sorry for the delay. You have a simple mistake in your TDF file: extra columns with empty characters. If you use the script version, you'll see the issue is not with the isospace plot, but happens when you load the TDF data. This is a general problem you'll encounter whenever using read.csv in R.

Mix and source data loading runs fine:

library(MixSIAR)
setwd("/home/brian/Documents/Isotopes/MixSIAR_help/issue_177")
mix.filename <- "V_consumer.csv"
mix <- load_mix_data(filename=mix.filename, 
                     iso_names=c("d13C","d15N"), 
                     factors="Species", 
                     fac_random=FALSE, 
                     fac_nested=FALSE, 
                     cont_effects=NULL)

source.filename <- "v_sources.csv"
source <- load_source_data(filename=source.filename, source_factors=NULL, conc_dep=FALSE, data_type="raw", mix)

But your original discrimination file throws an error:

discr.filename <- "v_discrimination.csv"
discr <- load_discr_data(filename=discr.filename, mix)
Error in `.rowNamesDF<-`(x, value = value) : 
  duplicate 'row.names' are not allowed
In addition: Warning message:
non-unique value when setting 'row.names': ‘’ 

When I create a new .csv file, deleting the "empty" (not actually empty) columns in Excel/LibreOffice, the TDF file loads fine and isospace plot is ok:

discr.filename <- "v_discrimination_delcols.csv"
discr <- load_discr_data(filename=discr.filename, mix)

plot_data(filename="isospace_plot", 
          plot_save_pdf=TRUE,
          plot_save_png=FALSE,
          mix,source,discr)
EllenMcKee commented 5 years ago

Hi Brian,

Thank you so much for your help - everything is running perfectly now!

Best,

Ellen


From: Brian Stock notifications@github.com Sent: 11 July 2019 17:59 To: brianstock/MixSIAR Cc: EllenMcKee; Author Subject: Re: [brianstock/MixSIAR] Error (#177)

Hi Ellen,

Sorry for the delay. You have a simple mistake in your TDF file: extra columns with empty characters. If you use the script version, you'll see the issue is not with the isospace plot, but happens when you load the TDF data. This is a general problem you'll encounter whenever using read.csv in R.

Mix and source data loading runs fine:

library(MixSIAR)

setwd("/home/brian/Documents/Isotopes/MixSIAR_help/issue_177")

mix.filename <- "V_consumer.csv"

mix <- load_mix_data(filename=mix.filename,

                 iso_names=c("d13C","d15N"),

                 factors="Species",

                 fac_random=FALSE,

                 fac_nested=FALSE,

                 cont_effects=NULL)

source.filename <- "v_sources.csv"

source <- load_source_data(filename=source.filename, source_factors=NULL, conc_dep=FALSE, data_type="raw", mix)

But your original discrimination file throws an error:

discr.filename <- "v_discrimination.csv"

discr <- load_discr_data(filename=discr.filename, mix)

Error in .rowNamesDF<-(x, value = value) :

duplicate 'row.names' are not allowed

In addition: Warning message:

non-unique value when setting 'row.names': ‘’

When I create a new .csv file, deleting the "empty" (not actually empty) columns in Excel/LibreOffice, the TDF file loads fine and isospace plot is ok:

discr.filename <- "v_discrimination_delcols.csv"

discr <- load_discr_data(filename=discr.filename, mix)

plot_data(filename="isospace_plot",

      plot_save_pdf=TRUE,

      plot_save_png=FALSE,

      mix,source,discr)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/brianstock/MixSIAR/issues/177?email_source=notifications&email_token=AMOBA2TUQOTY53QYVBYFYELP65YI7A5CNFSM4H46F6L2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZXP5GA#issuecomment-510590616, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AMOBA2WXYFBZF2TUEJWKZ73P65YI7ANCNFSM4H46F6LQ.

morgandobroski commented 3 years ago

Hi Brian,

I am having the same issue where it says: Error in plot_data(filename = "isospace_plot", plot_save_pdf = TRUE, plot_save_png = FALSE, : *** Error: Source names do not match in source and discr data files. Please check your source and discr data file row names.

All of my mix, source, and discrimination data loaded fine. My code is below.

mix.filename<-"C:/Users/morga/Documents/Data Analysis/Stable isotope analysis/mixSIAR/mixture.csv"

mix<-load_mix_data(filename=mix.filename, iso_names=c("d13c", "d15n"), factors=c("species"), fac_random=(FALSE), fac_nested=(FALSE), cont_effects=NULL)

source.filename<-"C:/Users/morga/Documents/Data Analysis/Stable isotope analysis/mixSIAR/source.csv"

source<-load_source_data(filename=source.filename, source_factors=NULL, conc_dep=FALSE, data_type="raw",mix)

discr.filename<-"C:/Users/morga/Documents/Data Analysis/Stable isotope analysis/mixSIAR/discrimination.csv" discr<-load_discr_data(filename=discr.filename, mix)

plot_data(filename="isospace_plot", plot_save_pdf=TRUE, plot_save_png=FALSE, mix, source, discr, return_obj=FALSE)

Here are the headers of my source and discrimination file.

A tibble: 5 x 5

Source Meand13c SDd13c Meand15n SDd15n

1 Graminoid 2.77 0.753 2.32 0.168 2 Herb 2.77 0.753 2.32 0.168 3 Lichen 2.77 0.753 2.32 0.168 4 Moss 2.77 0.753 2.32 0.168 5 Shrub 2.77 0.753 2.32 0.168 # A tibble: 6 x 3 Source d13c d15n 1 Graminoid -28.0 2.34 2 Graminoid -29.0 -0.159 3 Graminoid -28.0 2.64 4 Graminoid -28.8 0.00958 5 Graminoid -28.6 -2.22 6 Herb -27.9 -0.197 Do you have any suggestions? Thanks! Morgan
brianstock commented 3 years ago

Hi Morgan,

Have you checked all the rownames in your loaded source and discr data? I.e. what do you get when you run the code below? They should match.

source <- read.csv(source.filename)
discr <- read.csv(discr.filename)
unique(source$Source)
unique(discr$Source)
morgandobroski commented 3 years ago

Hi Brian,

There was an extra space in one of my source labels for my discrimination factors. It is working now!

Thank you,

Morgan


From: Brian Stock notifications@github.com Sent: Wednesday, January 20, 2021 5:30:23 PM To: brianstock/MixSIAR MixSIAR@noreply.github.com Cc: Morgan Dobroski dobroskm@myumanitoba.ca; Comment comment@noreply.github.com Subject: Re: [brianstock/MixSIAR] Error loading discrimination data (#177)

Hi Morgan,

Have you checked all the rownames in your loaded source and discr data? I.e. what do you get when you run the code below? They should match.

source <- read.csv(source.filename) discr <- read.csv(discr.filename) unique(source$Source) unique(discr$Source)

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/brianstock/MixSIAR/issues/177#issuecomment-764023967, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ASRH3CPPIQYYLCRG5RJDGLTS25RQ7ANCNFSM4H46F6LQ.