Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pca_from_genind.r not using default colour option. #17

Open
erondeau opened this issue Jan 26, 2021 · 1 comment
Open

pca_from_genind.r not using default colour option. #17

erondeau opened this issue Jan 26, 2021 · 1 comment
Labels
bug Something isn't working enhancement New feature or request

Comments

@erondeau
Copy link
Collaborator

No description provided.

@erondeau
Copy link
Collaborator Author

erondeau commented Jan 26, 2021

Issue is in pca_from_genind.r, colour_file = NULL. If is.null(colour_file), it creates a pallette.

  if(is.null(colour_file)){
    
    # Set colours default
    library(RColorBrewer)
    cols1 <- brewer.pal(n = nPop(my.data), name = "Paired")
    cols2 <- brewer.pal(n = (nPop(my.data)-length(cols1)), name = "Spectral")
    cols <- c(cols1, cols2)
    
  } else if(!is.null(colour_file)){
    
    # Reporting
    print(paste0("Using custom colours file from ", colour_file))
    
    # Input colour file
    colours.df <- read.table(file = colour_file, header = T, sep = ",", stringsAsFactors = F)
    
  }

However, later in the script, it filters colours.df to create the colours and then ordered_colours df.

  ## Create a colours vector
  # Select only the pops that are in the data
  colours <- filter(colours.df, collection %in% unique(pca.scores$pop))
  
  # Put into alphabetic order by collection (the plotting order, and legend order)
  colours <- colours[order(colours$collection), ]

Because this isn't created in the if/else above when colours.file = NULL, the script bails. Should be easy to patch, but won't address it at the moment.

@erondeau erondeau added bug Something isn't working enhancement New feature or request labels Jan 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant