search for: dendrapply

Displaying 20 results from an estimated 25 matches for "dendrapply".

2023 Feb 23
1
`dendrapply` Enhancements
Hi everyone, My apologies if this isn?t the right place to submit this?I?m new to the R-devel community and still figuring out what is where. If people want to skip my writeup and just look at the code, I?ve made a repository for it here: https://github.com/ahl27/new_dendrapply/tree/master. I?m not quite sure how to integrate it into a fork of R-devel; the package structure is different from what I?m used to. I had written a slightly improved version of dendrapply for one of my research projects, and my advisor encouraged me to submit it to the R project. It took me long...
2005 May 18
0
dendrogram and dendrapply
Hi all, I think I have some problems to use correctly the function dendrapply. Let suppose dend is a dendrogram object. I would likde to know the cardinal number of leaves depending of each node of the tree dend. It is right that the command attr(dend,"members") gives the total number of leaves, and attr(dend[[1]],"members") gives the number of leaves f...
2007 Nov 25
2
accessing the "address" of items in a recursive list
...s") I would like to print the "address" of the smaller dendrograms on the edge similar to this: addr <- function(n) { if(!is.leaf(n)) { attr(n, "edgetext") <- paste("height of",(attr(n,"height")) } n } labeledDends <- dendrapply(dend, addr) Where "i,j,k" is printed instead of "height". But I have not been able to figure out how to ask each dendrogram its address within the dendrapply function. Can anyone help me with this? Many thanks, Jesse PhD Student in Social Science Syracuse University
2023 Mar 23
1
`dendrapply` Enhancements
Hello Aidan, Sorry for dropping this for a while. ? Thu, 2 Mar 2023 21:03:59 +0000 "Lakshman, Aidan H" <AHL27 at pitt.edu> ?????: > //after > curnode = eval(lang3(R_Bracket2Symbol, parent->node, DEND_IND), env); lang3() always constructs a new language object. If you do end up using eval(), it may make sense to move lang3() out of the loop and reuse the existing object
2013 Jan 16
1
dendrogram stops!
Dear I am using the 'as.dendrogram' function from the 'stats' library to convert from an hclust object to a dendrogram with a dataset of size ~30000 (an example code is below). I need the dendrogram structure to use the "dendrapply" and "attributes" functions and to access the child nodes, I do not need any of the plot properties. The problem is that it takes an infinite amount of time to convert and it uses a lot of memory. Could you please let me know which part of the code (the link is below) takes th...
2009 Apr 03
0
dendrogram rect.hclust() not working?
...<- rep(0, length(order)) for (orderIndex in 1:length(order)) { # this puts a "name" to the permutation of leaves, done by hclust() orderedLabels[orderIndex] <- classes[order[orderIndex]] } scoreDendrogramObj <- as.dendrogram(scoreClusterObj) coloredLeafScoreDendrogramObj <- dendrapply(scoreDendrogramObj, markColoredLeaves) scoreDendrogramPlot <- plot(coloredLeafScoreDendrogramObj, horiz=FALSE, axes=FALSE) significantClustersInScoreDendrogramObj <- dendrapply(coloredLeafScoreDendrogramObj, markSignificantClusters) -------------------- I have the local functions markC...
2005 Dec 12
1
dendrogram: how to obtain leaf height
...t" or "h" (which changes with "hang") and that is what I want. Obviously, the info is there (e.g., "str(dendrogram)"), I just don't see how to obtain it as I want. hc <- hclust(dist(USArrests), "ave") hcd <- as.dendrogram(hc, hang = 0.001) dendrapply(rev(hcd), hnode) ## None of the following work as I want hnode <- function(x) { ## nothing if (is.leaf(x)) print(x$height) } hnode <- function(x) { ## just prints if (is.leaf(x)) print(x) else NULL } hnode <- function(x) { ## doesn'...
2010 Jul 09
2
Ctree Question
Hello, I've been using ctree and have developed a 55 node - 28 terminal solution. As can be imagined, the plot is difficult to travel down each of the major branches. I've read the help files for ctree I saw where terminal nodes can be color coded. plot(airct, type = "simple") > plot(airct, terminal_panel = node_boxplot(airct, col = "blue", + fill = hsv(2/3,
2010 Apr 13
0
Coloring leaves in Dendrogram according to gene names
...ng dendrogram coloring. I would like to color each leaf in the dendrogram (dhc) according to a specific criterion. For me this criterion is the gene name. For this, I created a data.frame with 2 variables: The gene name and the corresponding color. Using the following function, adapted from "dendrapply {stats}", I still have the same color for the leaves. Using the standard function (with the my_colors[i]), I do have the leaves of different colors !!! The structure of "my_colors[i]" is the same as the structure of "color" !!! Do you have any idea on what is going wrong...
2012 Oct 24
0
recursive function on a structured list of lists (dendrogram)
...d like the label of the leaf and the height of the enclosing branch. A dendrogram example (from the help file of stats::dendrogram), and some functions showing how it is structured: hc <- hclust(dist(USArrests), "ave") dend1 <- as.dendrogram(hc) plot(dend1) str(dend1) Similarly to dendrapply(), I tried o recursively obtain from the tree a list including, for each member (leaf) the height of the list containing it. However, I fail to fully grasp how the 'recursiveness' is made within the function saving both elements at the leaf and branch levels. For reference the dendrapply f...
2007 Mar 09
1
dendrogram - got it , just need to label :)
Hi all, Hi Gavin, thx for your help i finally found out what i want to do and how to fix it. just needed to get some more level my cut level was too small... two question remain... a) can i somehow scale the twigs after cutting ? b) how can i label the nodes and how to label which one... thx !! -m.
2012 May 24
4
Manually modifying an hclust dendrogram to remove singletons
...of items in each cluster, and therefore avoid singletons. e.g. in this example, you can see that Hawaii is split off onto its own at quite a high level. I would like to avoid having a single item clustered on its own like this. How can I achieve this? I have tried manually modifying the tree using dendrapply but have not been able to produce a valid solution thus far.. Suggestions are welcome. Best wishes, Mark
2017 Mar 23
1
A question on stats::as.hclust.dendrogram
...hat s is a nested list? Currently I have a case where a dendrogram object is breaks at this line, because s is a nested list: >str (s) List of 2 $ : int -779 $ :List of 2 ..$ : int -625 ..$ : int 15 I'm unsure if my dendrogram was malformed in the first place, since I was trying to use dendrapply. So, my question is: for that particular check, why use stopifnot(length(s) == 2L, all( vapply(s, is.integer, NA) )) instead of stopifnot(length(s) == 2L, all( vapply(unlist(s), is.integer, NA) ))? I appreciate your time and I'm looking forward to your response. Cheers, Man Chun John Ma,...
2005 Jul 11
1
indexing into and modifying dendrograms
...sociate with the node than the edge ## but current plotting function has no notion of nodetext addE <- function(n) { if(!is.leaf(n)) { attr(n, "edgePar") <- list(p.col="plum") attr(n, "edgetext") <- attr(n,"cNum") } n } dend2 <- dendrapply(dend1, addE) ## overlays the cNum ("cluster number") attribute on dendrogram plot(dend2, main = "dend2") ## why does no plum polygon appear around the '4' for the root ## edge? ## swap order of clusters 2 and 3, ## i.e. 'flip' cluster 4 dend3 <- dend2 dend3[[...
2007 Jun 13
2
Formatted Data File Question for Clustering -Quickie Project
...= list(col="gray", lwd=2), horiz = TRUE) addE <- function(n) { if(!is.leaf(n)) { attr(n, "edgePar") <- list(p.col="plum") attr(n, "edgetext") <- paste(attr(n,"members"),"members") } n } d3e <- dendrapply(d3, addE) plot(d3e, nodePar= nP) plot(d3e, nodePar= nP, leaflab = "textlike") -------------------------------------------------------- This information is being sent at the recipient's request or...{{dropped}}
2007 Nov 29
1
coloring leaves in clustering
Hello everyone, I wanted to know if it was possible to change the color of certain leaves in a hclust object in order to make my graph more readable. I know I can color certain groups but I would like to enter a vector telling the plot function which leaves to color in which color. Thanks in advance, Eleni [[alternative HTML version deleted]]
2009 Jul 09
0
Node colors in pvclust
Is there a way to assign color to nodes as with hclust/as.dendrogram/dendrapply when using pvclust? The problem is that as.dendrogram isn't working on the pvclust objects. library(pvclust) pvc <- pvclust(matrix, nboot=1000) plot(pvc) -- View this message in context: http://www.nabble.com/Node-colors-in-pvclust-tp24405329p24405329.html Sent from the R help mailing li...
2011 Sep 26
0
horizontal labels for a dendrogram
...bel] lab_color <- ifelse(labx == "A", "black", ifelse(labx == "B", "red", "green")) attr(n, "nodePar") <- c(att$nodePar, lab.col = lab_color, pch = NA) attr(n, "label") <- labx } n } # lab.col = lab_color, res2 = dendrapply(res, chlab) print(res2) pdf("dendrogram.pdf",width=5,height=2.5,pointsize=8,paper='special') par(mai=c(0.5,0.5,0.2,0.2)) plot(res2) dev.off() This works nicely with the exception of one detail: the labels are perpendicular to the normal reading direction. I'm aware of the l...
2005 Dec 16
2
dendrogram branches with different lty
Dear r-list, I am trying to visually seperate the two main clusters of a dendrogram. The idea is to use: 'edgePar=list(lty=3)' for 'dend1[[1]]' and 'edgePar=list(lty=1)' for 'dend1[[2]]' I have not found a way to solve this. Any suggestions? Patrick hc <- hclust(dist(USArrests), "ave") (dend1 <- as.dendrogram(hc)) par(mfrow=c(2,2)) plot(dend1)
2009 Jun 19
1
Drawing dendrogram
Dear all, I would like to draw a dendrogram and mark some parts/branches (by using "segments") including their labels. If I draw it without specifying the length of x axix, I am able to do that (as in My dendrogram 1 of the following codes). However, if I want to specify the x axix, I am not able to draw marking line (by using "segments") including labels (as in My dendrogram