We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
It would be great if
ldfast()
data.frame
Thanks to Heather Tuttle for the suggestion.
As a workaround until I make this a feature, you can use:
library(updog) library(ldsep) library(reshape2) ## Get data and fit ldfast ---- data("uit", package = "ldsep") gp <- format_multidog(x = uit, varname = paste0("Pr_", 0:4)) ldout <- ldfast(gp = gp, type = "r2") ## Format to data frame ---- colnames(ldout$ldmat) <- rownames(ldout$ldmat) <- dimnames(gp)$snp ldout$ldmat[lower.tri(ldout$ldmat, diag = TRUE)] <- NA lddf <- melt(ldout$ldmat, na.rm = TRUE) lddf
You can then use a tool like merge() or dplyr::left_join() to add genomic positions to this data frame.
merge()
dplyr::left_join()
The text was updated successfully, but these errors were encountered:
To finish off this example, and provide code for an LD decay plot (as also suggested by @lfelipe-ferrao), here is some quick and dirty code:
library(dplyr) library(ggplot2) library(scam) ## monotone constraint ## Suppose we have the following genotype locations dfloc <- data.frame(SNP = rownames(ldout$ldmat), loc = 1:10) ## Merge LD estimates lddf |> left_join(dfloc, by = c("Var1" = "SNP")) |> left_join(dfloc, by = c("Var2" = "SNP")) |> rename(SNP1 = Var1, SNP2 = Var2, r2 = value, Loc1 = loc.x, Loc2 = loc.y) |> mutate(dist = abs(Loc1 - Loc2)) |> distinct(SNP1, SNP2, .keep_all = TRUE) -> lddf ## Make plot ggplot(data = lddf, mapping = aes(x = dist, y = r2)) + geom_point() + geom_smooth(method = scam, formula = y ~ s(x, bs = c("mdcx", k = 8)), se = FALSE)
Sorry, something went wrong.
No branches or pull requests
It would be great if
ldfast()
kept SNP names (as row and column names)ldfast()
allowed for a return type ofdata.frame
ldfast()
had an option to keep SNP locations.Thanks to Heather Tuttle for the suggestion.
As a workaround until I make this a feature, you can use:
You can then use a tool like
merge()
ordplyr::left_join()
to add genomic positions to this data frame.The text was updated successfully, but these errors were encountered: