bmansfeld / QTLseqr

QTLseqr is an R package for QTL mapping using NGS Bulk Segregant Analysis
64 stars 42 forks source link

Help #37

Closed mdga337 closed 3 years ago

mdga337 commented 3 years ago

Hello !

I just have a couple questions about how to edit the generated graphs. is this possible ? I would like to change the background and maybe add some more details to the Axis, my data only shows 0 and 100 in the horizontal axis and would like it to show every 20 in the scale.

In another note, i noticed that when i tried to plot deltaSNP, I don't get any of the confidence intervals some short lines would appear in some regions. along with this i always get a message saying that there were a high amount of rows that had to be removed because they contained missing values. this is the message:

: Removed 55135 row(s) containing missing values (geom_path).

but checking the file for # of NAs i can only find 35699

and my plot showing only the 95 interval and not 99

image

thanks !

Marco

bmansfeld commented 3 years ago

Hey Marco, Thanks for your interest in QTLseqr. Hopefully it's helpful in your work. So plotQTLStats() is just a wrapper for ggplot to pull out the data and format the plots. The figures can be manipulated with any ggplot code. For example, you can do this:


# Plot chr1 for example
p <- plotQTLStats(
    SNPset = df_filt,
    var = "deltaSNP",
    plotIntervals = TRUE,
    q = 0.01, subset = "Chr1"
)

p +  
    theme_bw() +  # this will change the theme to black and white
    scale_x_continuous(breaks = seq(1, 100e6, by = 20e6), name = "Genomic position") + # this will change the x-axis 
    ylim(-1, 1) # and this will resolve the CI plotting which get cut off because of the y-axis limits

Hope this helps! Ben

mdga337 commented 3 years ago

Ben

I've been trying to plot the actual SNPs as dots in this previous graph, but I am running out of ideas with GGPLOT2, is there a way to do this ? I'd like to add the deltaSNP to the QTLstats plot. I'm curious to see the noise and distribution of the SNPs.

I am assuming it would be very similar to the previous solution, but is there an specific way to plot the SNPindex for high bulk and a second graph for the low bulk?

Thanks !

Marco

bmansfeld commented 3 years ago

Hey Marco, plotQTLStats has a line parameter. If it is set to TRUE then the figures will plot lines, if set to FALSE it will plot points.

To plot the raw SNP index plots for high and low bulk try something like this:

### NOT RUN

#first gather the data to long format and save as new data frame something like this:
SNPindex_df <- df_filt pivot_longer(names_to = "SNPindex", cols = c(SNPindex.LOW, SNPindex.HIGH))

# then plot the SNPindex as points and facet by SNPindex column from above. 
# You might want to set the alpha as below to see overlapping points

ggplot(data = SNPindex_df) + 
    geom_point(aes(x = POS, y = value), alpha = 0.3) +
    facet_grid(~ SNPindex)

Hopefully this helps you get in the right direction. Let me know if you have more questions. I'll leave the issue open