Révision 6e0010bc src/R/nucleominer.R
b/src/R/nucleominer.R | ||
---|---|---|
1835 | 1835 |
plot_common_unrs = FALSE, ##<< Plot (or not) unaligned nucleosomal refgions (UNRs). |
1836 | 1836 |
plot_wp_nucs_4_nonmnase = FALSE, ##<< Plot (or not) clusters for non inputs samples. |
1837 | 1837 |
plot_chain = FALSE, ##<< Plot (or not) clusterised nuceosomes between mnase samples. |
1838 |
plot_sample_id = FALSE, ##<< Plot (or not) the sample id for each sample. |
|
1838 | 1839 |
aggregated_intra_strain_nucs = NULL, ##<< list of aggregated intra strain nucs. If NULL, it will be computed. |
1839 | 1840 |
aligned_inter_strain_nucs = NULL, ##<< list of aligned inter strain nucs. If NULL, it will be computed. |
1840 | 1841 |
height = 10, ##<< Number of reads in per million read for each sample, graphical parametre for the y axis. |
1842 |
main=NULL, ##<< main title of the produced plot |
|
1843 |
xlab=NULL, ##<< xlab of the produced plot |
|
1844 |
ylab="#reads (per million reads)", ##<< ylab of the produced plot |
|
1841 | 1845 |
config=NULL ##<< GLOBAL config variable |
1842 | 1846 |
){ |
1843 | 1847 |
returned_list = list() |
... | ... | |
1859 | 1863 |
y_max_glo = max(ylim_glo) |
1860 | 1864 |
delta_y_glo = y_max_glo - y_min_glo |
1861 | 1865 |
# Plot main frame |
1862 |
plot(c(x_min_glo,x_max_glo), c(0,0), ylim=ylim_glo, col=0, yaxt="n", ylab="#reads (per million reads)", xlab=paste("Ref strain:", replicates[[1]][[1]]$strain, "chr: ", replicates[[1]][[1]]$roi$chr), main="NucleoMiner2" ) |
|
1866 |
if (is.null(xlab)) { |
|
1867 |
xlab = paste("Ref strain:", replicates[[1]][[1]]$strain, "chr: ", replicates[[1]][[1]]$roi$chr) |
|
1868 |
} |
|
1869 |
plot(c(x_min_glo,x_max_glo), c(0,0), ylim=ylim_glo, col=0, yaxt="n", ylab=ylab, xlab=xlab, main=main ) |
|
1863 | 1870 |
axis(2, at=0:(nb_rank_glo*2) * delta_y_glo / (nb_rank_glo*2), labels=c(rep(c(height/2,0),nb_rank_glo),height/2)) |
1864 | 1871 |
# Go |
1865 | 1872 |
replicates_wp_nucs = list() |
... | ... | |
1878 | 1885 |
# computing sample parameters |
1879 | 1886 |
sample = samples[[sample_rank]] |
1880 | 1887 |
y_lev = y_min + (sample_rank - 0.5) * delta_y/nb_rank |
1881 |
text(x_min_glo, y_lev + height/2 - delta_y_glo/100, labels=paste("(",sample$id,") ",sample$strain, " ", sample$marker, sep="")) |
|
1888 |
if (plot_sample_id) { |
|
1889 |
text(x_min_glo, y_lev + height/2 - delta_y_glo/100, labels=paste("(",sample$id,") ",sample$strain, " ", sample$marker, sep="")) |
|
1890 |
} |
|
1882 | 1891 |
|
1883 | 1892 |
if (sample$roi[["begin"]] < sample$roi[["end"]]) { |
1884 | 1893 |
x_min = sample$roi[["begin"]] |
... | ... | |
1940 | 1949 |
if (length(nucs$center) > 0) { |
1941 | 1950 |
col = 1 |
1942 | 1951 |
for (i in 1:length(nucs$center)) { |
1952 |
foo<<-nucs |
|
1943 | 1953 |
if (change_col) { |
1944 | 1954 |
col = col + 1 |
1945 |
} |
|
1955 |
} else { |
|
1956 |
col = "blue" |
|
1957 |
} |
|
1946 | 1958 |
nuc = nucs[i,] |
1947 | 1959 |
involved_reads = filter_tf_inputs(reads, sample$roi$chr, nuc$lower_bound, nuc$upper_bound, nuc_width = nuc$width) |
1948 | 1960 |
involved_signs = apply(t(involved_reads[,3]), 2, function(strand) { if (strand == "F") return(1) else return(-1)}) |
... | ... | |
1962 | 1974 |
lines(sign(x_min) * delta_x + shift, dnorm(delta_x, mean(flatted_reads[[2]]), sd(flatted_reads[[2]])) * length(flatted_reads[[2]]) * -1 * sign(x_min) * height/5 + y_lev, col=col) |
1963 | 1975 |
} |
1964 | 1976 |
if (plot_gaussian_unified_reads ) { |
1965 |
lines(sign(x_min) * delta_x + shift, dnorm(delta_x, mean(flatted_reads[[3]]), sd(flatted_reads[[3]])) * length(flatted_reads[[3]]) * height/5 + y_lev, col=col, lty=2)
|
|
1977 |
lines(sign(x_min) * delta_x + shift, dnorm(delta_x, mean(flatted_reads[[3]]), sd(flatted_reads[[3]])) * length(flatted_reads[[3]]) * height/5 + y_lev, col=col, lty=1)
|
|
1966 | 1978 |
} |
1967 | 1979 |
if (plot_ellipse_nucs) { |
1968 | 1980 |
# require(plotrix) |
... | ... | |
2007 | 2019 |
tmp_track = unlist(tf_nucs$track) |
2008 | 2020 |
tmp_track_prev = tmp_track[-length(tmp_track)] |
2009 | 2021 |
tmp_track_next = tmp_track[-1] |
2010 |
tmp_track_inter = signif(tmp_track_prev - tmp_track_next) * (abs(tmp_track_prev - tmp_track_next) > 1) * 25 |
|
2022 |
# tmp_track_inter = signif(tmp_track_prev - tmp_track_next) * (abs(tmp_track_prev - tmp_track_next) > 1) * 25 |
|
2023 |
if (is.null(config$TRACK_LOD_OFFSET)) { |
|
2024 |
config$TRACK_LOD_OFFSET = 0 |
|
2025 |
} |
|
2026 |
tmp_track_inter = signif(tmp_track_prev - tmp_track_next) + config$TRACK_LOD_OFFSET * 25 |
|
2011 | 2027 |
tmp_x_prev = tmp_x[-length(tmp_x)] |
2012 | 2028 |
tmp_x_next = tmp_x[-1] |
2013 | 2029 |
need_shift = apply(t(tmp_x_next - tmp_x_prev), 2, function(delta){ delta < 50}) |
... | ... | |
2025 | 2041 |
points(tmp_x, tmp_y, cex=4, pch=16, col="white") |
2026 | 2042 |
points(tmp_x, tmp_y, cex=4, lw=2) |
2027 | 2043 |
text(tmp_x, tmp_y, 1:nrow(tf_nucs)) |
2028 |
text(tmp_x_inter, tmp_y_inter, tmp_lod_inter, srt=90, cex=0.9, bg = "yellow")#, col=(tmp_lod_inter < 20) + 2) |
|
2044 |
if (is.null(config$LEGEND_LOD_POS)) { |
|
2045 |
pos = 2 |
|
2046 |
} else { |
|
2047 |
pos = config$LEGEND_LOD_POS |
|
2048 |
} |
|
2049 |
text(tmp_x_inter, tmp_y_inter, tmp_lod_inter, cex=1.5, pos=pos) |
|
2029 | 2050 |
} |
2030 | 2051 |
|
2031 | 2052 |
if (plot_wp_nucs | plot_fuzzy_nucs | plot_common_nucs ) { |
... | ... | |
2117 | 2138 |
common_nuc_results = list() |
2118 | 2139 |
common_nuc_results[[paste(combi[1], combi[2], sep="_")]] = aligned_inter_strain_nucs |
2119 | 2140 |
unrs = get_unrs(combi, roi, cur_index, wp_maps, fuzzy_maps, common_nuc_results, config = config) |
2120 |
rect(sign(x_min[[1]]) * unrs$lower_bound + shift[[1]], y_min[[1]], sign(x_min[[1]]) * unrs$upper_bound + shift[[1]], y_max[[2]], col=adjustcolor(4, alpha.f = 0.3), border=1)
|
|
2141 |
rect(sign(x_min[[1]]) * unrs$lower_bound + shift[[1]], y_min[[1]], sign(x_min[[1]]) * unrs$upper_bound + shift[[1]], y_max[[2]], border=4, lw=3, col=adjustcolor(4, alpha.f = 0.05))
|
|
2121 | 2142 |
} |
2122 | 2143 |
|
2123 | 2144 |
} |
Formats disponibles : Unified diff