Menu

charting maps

rtadmorl
2016-07-05
2016-07-28
  • rtadmorl

    rtadmorl - 2016-07-05

    Hello,
    Does anyone have a reccomendation of a software that will visualize the map created by LEPMAP2?
    My map files are ready and I would like to chart my LGs.
    Many thanks!
    Roni Tadmor-Levi
    Hebrew University

     

    Last edit: rtadmorl 2016-07-05
    • Federico Calboli

      Hi, I just wrote the code in R especially. If you email me at

      federico DOT calboli AT helsinki DOT fi

      I can send you the code. Please note it works 'for my pipeline', so you might need to adapt it, possibly quite a bit.

       

      Last edit: Federico Calboli 2016-07-11
  • Pasi Rastas

    Pasi Rastas - 2016-07-11

    Dear Roni Tadmor-Levi,

    Thank you for your question.

    Sorry I cannot help as I have not ever charted my maps it that way. Maybe you or I could ask Federico as he did the charting in the Lep-MAP2 paper.

    Cheers,
    Pasi

     
  • rtadmorl

    rtadmorl - 2016-07-19

    Many thanks to you both, I will e-mail Federico.

     
  • Federico Calboli

    Here is the code I used, for reference.

    PART 1: turn LM2 output in csv files

    run this part in a bash shell (you need to be in the directory the files have been stored in).

    sed -i '' $'s/\t/,/g' .txt
    sed -i '' 's/)/,/g'
    .txt
    sed -i '' 's/(//g' *.txt

    for file in *.txt; do
    mv "$file" "basename $file .txt.csv"
    done

    for file in *csv; do
    sed -i '' '1,2d' $file
    done

    for file in *csv; do
    sed -i '' '$d' $file
    done

    sed -i '' 's/#//' *csv

    PART 2: actually plot the chromosomes:

    run the following in R NOTE I HAVE 21 chromosomes, change the instances of 21 to your number of chromosomes

    mf = vector(length = 21, mode = 'list')
    sa = vector(length = 21, mode = 'list')

    for (i in 1:21){
    mf[[i]] = read.csv(paste('chr', i, '.MF.csv', sep = ''), na.strings = '', col.names = c('marker', 'm_map', 'f_map','error', 'duplicate','phase'))
    sa[[i]] = read.csv(paste('chr', i, '.SA.csv', sep = ''), na.strings = '', col.names = c('marker', 'map', 'map','error', 'duplicate', 'phase'))
    }

    mfx= lapply(mf, function(x){x[!is.na(x$duplicate),1]})
    sax = lapply(sa, function(x){x[!is.na(x$duplicate),1]})
    xx = unique(c(unlist(mfx), unlist(sax)))

    mf = lapply(mf, function(x){x[!is.element(x[,1], xx), ]})
    sa = lapply(sa, function(x){x[!is.element(x[,1], xx), ]})

    this should print out TRUE in all instances

    for(i in 1:21){
    print(c(as.character(i), identical(mf[[i]][,1], sa[[i]][,1])))
    }

    for(i in 1:21){
    mf[[i]]$LG = i
    }

    for(k in 1:21){
    mf[[k]] = data.frame(LG = mf[[k]]$LG, marker = mf[[k]][,1], m_map = mf[[k]][,2], f_map = mf[[k]][,3], map = sa[[k]][,2], duplicate = mf[[k]][,5], error = mf[[k]][,4], phase = mf[[k]][,6])
    }

    wholemap = NULL
    for(i in 1:21){
    wholemap = rbind(wholemap, mf[[i]])
    }

    wholemapm.maps = tapply(wholemap$m_map, wholemap$LG, unique)
    wholemapf.maps = tapply(wholemap$f_map, wholemap$LG, unique)
    wholemap.maps = tapply(wholemap$map, wholemap$LG, unique)

    plot.maps = function(chroms, main = 'Cromosome Plot', xlim = NULL, ylab = 'Linkage Group'){
    upper.l = max(unlist(chroms))
    lower.l = 0
    lower.l2 = lower.l - upper.l0.025
    upper.l2 = upper.l
    1.025
    if(length(xlim) == 2)
    nexlim = xlim
    else
    nexlim = c(lower.l2, upper.l2)
    plot(chroms[[1]], rep(1, length(chroms[[1]])), pch = '|', xlim = nexlim, ylim = c(0,22), xlab = 'cM', ylab = ylab, main = main, type = 'n', yaxt = 'n')
    axis(side = 2, at = 1:21, labels = 1:21, las= 1)

    ##### axis(side = 1, at = (seq(lower.l, upper.l, by = 25)))

    for(i in 1:21){
    maxy = max(chroms[[i]])
    segments(0.75, i, maxy-0.75, i, col = 'lightgrey', lwd = 7)
    points(chroms[[i]], rep(i, length(chroms[[i]])), pch = '|')
    }
    }

    par(mfrow = c(1,3))

    you might have to adjust the xlims

    plot.maps(wholemapm.maps, main = 'Male', xlim = c(0,420))
    plot.maps(wholemapf.maps, main = 'Female', xlim = c(0,420))
    plot.maps(wholemap.maps, main = 'Sex Averaged', xlim = c(0,420))

     
  • Stephen Trevoy

    Stephen Trevoy - 2017-05-03

    Hi there,

    Some questions for formatting the .csv files so the R script runs properly:

    1) Do chromosomes need to be separated into their own .csv files?
    2) Do families need to be separated into their own .csv files?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.