From microbeatic at gmail.com Thu Mar 6 19:46:23 2014 From: microbeatic at gmail.com (Migun Shakya) Date: Thu, 6 Mar 2014 13:46:23 -0500 Subject: [genoPlotR-help] genoplotR: setting up colors for dna segments based on name Message-ID: Hello, Is there a way to set the color of dna segments based on the name of the gene? I have set of genes with same name but from different genomes, i wanted to color the arrows based on its name. Right now when i read in my tab delimited file and convert it to dna_segs, it adds the default color blue. Thank you migee. From guy.lionel at gmail.com Fri Mar 7 09:14:29 2014 From: guy.lionel at gmail.com (Lionel Guy) Date: Fri, 07 Mar 2014 09:14:29 +0100 Subject: [genoPlotR-help] genoplotR: setting up colors for dna segments based on name In-Reply-To: References: Message-ID: <53197FE5.6030600@gmail.com> Hi Migee, There are various ways to do that. One is to have an extra "col" column in your tab file, giving colors for each gene. Color names have to be R-compatible, (e.g. look at colors() in R). Otherwise, if you have a list of genes and a matching list if colors, you could do something like this: ## Just loading data, replacing names with bogus gene names library(genoPlotR) data(three_genes) dna_segs[[1]]$name <- c("dnaA", "dnaA", "modB") dna_segs[[2]]$name <- c("dnaA", "dnaC", "modD") dna_segs[[3]]$name <- c("dnaC", "blaB", "modD") ## Creating a lookup table with gene names in one colum and colors in the second lt <- data.frame(name=c("dnaA", "dnaC", "modB"), col=c("red", "green", "yellow"), stringsAsFactors=FALSE) ## Attributing colors to genes for (i in 1:length(dna_segs)){ dna_segs[[i]]$col <- "black" for (j in 1:nrow(lt)){ dna_segs[[i]]$col[dna_segs[[i]]$name == lt$name[j]] <- lt$col[j] } } ## Showing the result annots <- list() for (i in 1:length(dna_segs)){ annots[[i]] <- auto_annotate(dna_segs[[i]], names=dna_segs[[i]]$name) } plot_gene_map(dna_segs, comparisons, annotations=annots) If you still have problems, please send (part of) the data you have, it would help to solve it! Cheers, Lionel On 03/06/2014 07:46 PM, Migun Shakya wrote: > Hello, > > Is there a way to set the color of dna segments based on the name of the gene? > > I have set of genes with same name but from different genomes, i wanted to color the arrows based on its name. > Right now when i read in my tab delimited file and convert it to dna_segs, it adds the default color blue. > > > > Thank you > > migee. > _______________________________________________ > genoPlotR-help mailing list > genoPlotR-help at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/genoplotr-help > From microbeatic at gmail.com Fri Mar 7 13:18:13 2014 From: microbeatic at gmail.com (Migun Shakya) Date: Fri, 7 Mar 2014 07:18:13 -0500 Subject: [genoPlotR-help] genoplotR: setting up colors for dna segments based on name In-Reply-To: <53197FE5.6030600@gmail.com> References: <53197FE5.6030600@gmail.com> Message-ID: Thank you Lionel. I used the look up table approach, and it worked great. I was going to add the col column, but i was misthinking that it might get ignored when converting to dna_seg. Thank you again. Migee On Mar 7, 2014, at 3:14 AM, Lionel Guy wrote: > for (i in 1:length(dna_segs)){ > dna_segs[[i]]$col <- "black" > for (j in 1:nrow(lt)){ > dna_segs[[i]]$col[dna_segs[[i]]$name == lt$name[j]] <- lt$col[j] > } > } -------------- next part -------------- An HTML attachment was scrubbed... URL: From microbeatic at gmail.com Wed Mar 12 19:00:19 2014 From: microbeatic at gmail.com (Migun Shakya) Date: Wed, 12 Mar 2014 14:00:19 -0400 Subject: [genoPlotR-help] matching ordering of phylog or dna_segs object Message-ID: <3F573791-389D-4C29-82A1-92A2CDE471A2@gmail.com> Hello, In the help page for `plot_dna-segs`, it is mentioned that the solution for matching large number of `lines` with the corresponding phylogenetic tree is to do the following: "The solution is then to provide segments that are ordered in the same manner as the tree labels (or vice-versa)." However, i can?t find an obvious way to do it for phylog object or the dna_segs. My question is, is there any tutorial or method in the genoplotR package that tells us how to do it. Thank you again Migee -------------- next part -------------- An HTML attachment was scrubbed... URL: From lionel.guy at icm.uu.se Wed Mar 12 21:41:27 2014 From: lionel.guy at icm.uu.se (Lionel Guy) Date: Wed, 12 Mar 2014 21:41:27 +0100 Subject: [genoPlotR-help] matching ordering of phylog or dna_segs object In-Reply-To: <3F573791-389D-4C29-82A1-92A2CDE471A2@gmail.com> References: <3F573791-389D-4C29-82A1-92A2CDE471A2@gmail.com> Message-ID: <7F269429-467D-4E53-A712-808FD214B0E5@icm.uu.se> Hi Migee, There is no tutorial or method about that. One way to do that would the following: Provided that your tree leaves and the names of your dna_segs are exactly the same (and are unique), you simply reorder the list containing the dna_segs according to the names of the leaves of the tree. For example, say you have 4 segments: data(barto) # I'm making a fake tree: tree <- newick2phylog("(BQ:2.5,(BH:1.8,(BG:1,BB:0.8):1.9):3);") plot(tree) names(tree$leaves) # The dna_segs are ordered differently: names(barto$dna_segs) # I can now reorder the list containing the dna_segs according to the names of the leaves ds2 <- barto$dna_segs[names(tree$leaves)] # Now the dna_segs are ordered as the leaves, and I can plot accordingly: names(ds2) names(tree$leaves) plot_gene_map(ds2, tree=tree) Now of course, the comparisons need to be done accordingly, thus you need to compute BQ vs BH, BH vs BG, and BG vs BB. HTH, Lionel On 12 Mar 2014, at 19:00 , Migun Shakya wrote: > Hello, > > In the help page for `plot_dna-segs`, it is mentioned that the solution for matching large number of `lines` with the corresponding phylogenetic tree is to do the following: > > "The solution is then to provide segments that are ordered in the same manner as the tree labels (or vice-versa)." > > > However, i can?t find an obvious way to do it for phylog object or the dna_segs. > > My question is, is there any tutorial or method in the genoplotR package that tells us how to do it. > > > Thank you again > > Migee > _______________________________________________ > genoPlotR-help mailing list > genoPlotR-help at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/genoplotr-help -- Lionel Guy Molecular Evolution, Uppsala University, Uppsala, Sweden postal address: Box 596, SE-751 24 Uppsala; visiting address: BMC B7:213e, Husargatan 3, SE-752 37 Uppsala phone: +46 18 471 6129, mobile +46 73 976 0618 lionel.guy at icm.uu.se From microbeatic at gmail.com Thu Mar 13 22:14:45 2014 From: microbeatic at gmail.com (Migun Shakya) Date: Thu, 13 Mar 2014 17:14:45 -0400 Subject: [genoPlotR-help] matching ordering of phylog or dna_segs object In-Reply-To: <7F269429-467D-4E53-A712-808FD214B0E5@icm.uu.se> References: <3F573791-389D-4C29-82A1-92A2CDE471A2@gmail.com> <7F269429-467D-4E53-A712-808FD214B0E5@icm.uu.se> Message-ID: <5E1C727C-0DD2-4965-ADA7-A7B7568A4330@gmail.com> hi Lionel, That worked really well. Thank you much for the quick response. Migun On Mar 12, 2014, at 4:41 PM, Lionel Guy wrote: > Hi Migee, > > There is no tutorial or method about that. One way to do that would the following: > > Provided that your tree leaves and the names of your dna_segs are exactly the same (and are unique), you simply reorder the list containing the dna_segs according to the names of the leaves of the tree. For example, say you have 4 segments: > > data(barto) > # I'm making a fake tree: > tree <- newick2phylog("(BQ:2.5,(BH:1.8,(BG:1,BB:0.8):1.9):3);") > plot(tree) > names(tree$leaves) > # The dna_segs are ordered differently: > names(barto$dna_segs) > # I can now reorder the list containing the dna_segs according to the names of the leaves > ds2 <- barto$dna_segs[names(tree$leaves)] > # Now the dna_segs are ordered as the leaves, and I can plot accordingly: > names(ds2) > names(tree$leaves) > plot_gene_map(ds2, tree=tree) > > Now of course, the comparisons need to be done accordingly, thus you need to compute BQ vs BH, BH vs BG, and BG vs BB. > > HTH, > > Lionel > > On 12 Mar 2014, at 19:00 , Migun Shakya wrote: > >> Hello, >> >> In the help page for `plot_dna-segs`, it is mentioned that the solution for matching large number of `lines` with the corresponding phylogenetic tree is to do the following: >> >> "The solution is then to provide segments that are ordered in the same manner as the tree labels (or vice-versa)." >> >> >> However, i can?t find an obvious way to do it for phylog object or the dna_segs. >> >> My question is, is there any tutorial or method in the genoplotR package that tells us how to do it. >> >> >> Thank you again >> >> Migee >> _______________________________________________ >> genoPlotR-help mailing list >> genoPlotR-help at lists.r-forge.r-project.org >> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/genoplotr-help > > -- > Lionel Guy > Molecular Evolution, Uppsala University, Uppsala, Sweden > postal address: Box 596, SE-751 24 Uppsala; visiting address: BMC B7:213e, Husargatan 3, SE-752 37 Uppsala > phone: +46 18 471 6129, mobile +46 73 976 0618 > lionel.guy at icm.uu.se > > > > > > > > > > > > > _______________________________________________ > genoPlotR-help mailing list > genoPlotR-help at lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/genoplotr-help