Hi Eduardo, Thank you for the quick response. I tried your suggestion to convert the map_data columns, but unfortunately it didn't resolve the issue.
I've also provided some additional details from how the analysis was conducted.
This is how I read in the data:
data <- fread("211202_gbs_nov_2021_snps_10percent_miss_dp6_maf05_no_row_or_col_names.csv")
# Transpose data so that columns are markers and rows are individuals
data_t <- t(data)
# Convert data to matrix
data_t_m <- as.matrix(data_t)
And how I set column/row names:
# Set column names
colnames(data_t_m) <- map_data$Locus
# Create vector of individual names (based on row number)
named_samples = vector()
for(i in c(1:nrow(data_t_m))){
named_samples <- append(named_samples, paste0("Individual_", i))
}
# Set rownames
rownames(data_t_m) <- named_samples
I thought that maybe the chromosome names having strings in them could be affecting things, so I changed them:
# Change LG column to numeric
map_data[, LG := sub("ZPchr", "", LG)]
map_data[, LG := as.numeric(map_data$LG)]
# Change Position column to numeric
map_data[, Position := as.numeric(map_data$Position)]
This succeeded in changing the data types to numeric:
> class(map_data$LG)
[1] "numeric"
> class(map_data$Position)
[1] "numeric"
But did not affect the outcome of the analysis. I still get the same failure that I got before. Could there be some other latent problem? I know there are missing genotypes in my genotype matrix (but not in the map data--I checked that). Could that be the problem? Or is it problematic that the data aren't in -1,0,1 format?
My first attempt involved trying to change the 0,1,2 format by converting the data.table to a tibble:
data <- as_tibble(data) # convert data.table to tibble in order to do the "find and replace"
# Convert to -1,0,1 format; requires tidyverse
#data <- data %>% mutate_if(is.character, str_replace_all, pattern = '0', replacement = '-1')
#data <- data %>% mutate_if(is.character, str_replace_all, pattern = '1', replacement = '0')
#data <- data %>% mutate_if(is.character, str_replace_all, pattern = '2', replacement = '1')
Note: This also involved using stringsAsFactors = TRUE in the fread() function.
Which also involved converting the data type back to numeric:
# Convert data type back to numeric/integer from character. I thought it would help solve the issue of empty results. I was wrong-it didn't solve the problem--but also didn't appear to cause any problems.
class(data_t_m) <- "numeric"
But this was also messy and I'm not sure it's necessary to convert to -1,0,1 format. I suppose I could have also done this find+replace in Excel, but there are so much data that it crashes.