I am trying to extract the data that is being plotted by the plot_pxg() to crate the plot with ggplot instead of the R base.
What is the best way to go about this?
So far I have a function like this but its incomplete:
```
plot_pxg_ggplot <- function(pheno_name, loci){
# get the peak data related to the loci
loci_pheno_peak <- qtl_peak_loci %>% filter(
lodcolumn==pheno_name & manual_annotation_locus== loci)
# get the loci related marker data
loci_data <- loci_marker_data[[loci]]
# convert the data into long format
loci_data_long <- loci_data %>%
pivot_longer(
4:(ncol(loci_data)-1),
names_to ="lodcolumn",
values_to = "LOD") %>%
filter(lodcolumn == pheno_name)
# get the chromosome where the loci is located
chr <- unique(loci_data_long$chr)
# pheno data for the specified phenotype
pheno_data <- as.numeric(pheno[,pheno_name])
pheno_data_inverse_normal <- inverse_normal_transform(pheno_data)
names(pheno_data_inverse_normal) <- rownames(cross_basic$pheno)
# subset the allele probability data to only include the markers in the loci
# get the genotypes for the specified
genotype <- maxmarg(
probs = pr,
map = cross_basic$pmap,
chr = chr,
pos = loci_pheno_peak$pos
)
geno <- factor(genotype)
return(geno)
}
```
Thank you.