-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of ssh://github.com/dmgatti/AttieMetabolomics
- Loading branch information
Showing
4 changed files
with
37 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
################################################################################ | ||
# Make a histogram of the top QTL. | ||
# Given the harvested QTL, make a histogram of the top QTL. | ||
# Daniel Gatti | ||
# [email protected] | ||
# July 20, 2017 | ||
|
@@ -8,52 +8,42 @@ options(stringsAsFactors = F) | |
library(tidyverse) | ||
|
||
# Arguments: | ||
# input.file: full path to the *.rds qtl summary file. | ||
# input.file: full path to the *.csv qtl summary file. | ||
# output.file: full path to the output figure file as a PNG. | ||
# thr: LOD threshold to use when selecting QTL peaks. | ||
args = commandArgs(trailingOnly = TRUE) | ||
input.file = args[1] | ||
output.file = args[2] | ||
thr = as.numeric(args[3]) | ||
|
||
print(paste("INPUT.FILE=", input.file)) | ||
print(paste("OUPUT.FILE=", output.file)) | ||
print(paste("THR=", thr)) | ||
|
||
# Load in the data. | ||
data = readRDS(input.file) | ||
data = read.csv(input.file) | ||
data$chr = factor(data$chr, levels = c(1:19, "X")) | ||
|
||
# Load in markers. | ||
load(url("ftp://ftp.jax.org/MUGA/GM_snps.Rdata")) | ||
markers = GM_snps[rownames(data), 1:4] | ||
markers = GM_snps[, 1:4] | ||
markers[,2] = factor(markers[,2], levels = c(1:19, "X")) | ||
|
||
map = split(markers[,3], markers[,2]) | ||
chrlen = sapply(map, length) | ||
chrlen = chrlen[order(as.numeric(names(chrlen)))] | ||
chrlen.mb = sapply(map, max) | ||
chrsum = cumsum(chrlen) | ||
chrsum.mb = cumsum(c(0, chrlen.mb[-length(chrlen.mb)])) | ||
names(chrsum.mb) = names(chrlen) | ||
chrmid = c(1, chrsum[-length(chrsum)]) + chrlen / 2 | ||
names(chrmid) = names(chrlen) | ||
col = rep(c("grey50", "black"), 10) | ||
|
||
png(output.file, width = 1000, height = 800, res = 128) | ||
|
||
rs = rowSums(data > thr) | ||
ylim = range(rs) | ||
|
||
print(paste("YLIM = ", ylim)) | ||
# Add genome Mb to data. | ||
data = data.frame(data, gmb = data$pos + chrsum.mb[data$chr]) | ||
|
||
rs.df = data.frame(pos = 1:length(rs), rs = rs) | ||
rs.df = split(rs.df, markers[,2]) | ||
png(output.file, width = 1000, height = 800, res = 128) | ||
|
||
par(plt = c(0.08, 0.99, 0.12, 0.95)) | ||
plot(-1, -1, type = "l", las = 1, col = col, xlim = c(0, nrow(markers)), | ||
xaxt = "n", xlab = "", xaxs = "i", ylim = c(0, ylim[2]), | ||
ylab = "Number of Analytes") | ||
for(i in 1:length(rs.df)) { | ||
lines(rs.df[[i]][,1], rs.df[[i]][,2], col = col[i]) | ||
} | ||
mtext(side = 1, line = 1, at = chrmid, text = names(chrmid), cex = 1.5) | ||
ggplot(data, aes(x = pos)) + | ||
geom_histogram(binwidth = 2) + | ||
facet_grid(~chr) + | ||
theme(panel.spacing.x = unit(0.1, "lines")) | ||
|
||
dev.off() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters