홈>
아래 그림과 같이 가지가 채색 된 R의 덴드로 그램을 만들고 싶습니다.
지금까지 표준 덴드로 그램을 만들기 위해 다음 명령을 사용했습니다 :
d <- dist(as.matrix(data[,29])) # find distance matrix
hc <- hclust(d) # apply hirarchical clustering
plot(hc,labels=data[,1], main="", xlab="") # plot the dendrogram
원하는 결과를 얻기 위해이 코드를 어떻게 수정해야합니까?
도움을 주셔서 감사합니다.
- 답변 # 1
- 답변 # 2
와이즈 비즈 (도움말 문서).
예 :
dendrapply
제공하는 내용 :
- 답변 # 3
FigTree는 덴드로 그램을 만들 수 있습니다. 예를 들어이 논문을 참조하십시오.
R 거리 행렬# Generate data set.seed(12345) desc.1 <- c(rnorm(10, 0, 1), rnorm(20, 10, 4)) desc.2 <- c(rnorm(5, 20, .5), rnorm(5, 5, 1.5), rnorm(20, 10, 2)) desc.3 <- c(rnorm(10, 3, .1), rnorm(15, 6, .2), rnorm(5, 5, .3)) data <- cbind(desc.1, desc.2, desc.3) # Create dendrogram d <- dist(data) hc <- as.dendrogram(hclust(d)) # Function to color branches colbranches <- function(n, col) { a <- attributes(n) # Find the attributes of current node # Color edges with requested color attr(n, "edgePar") <- c(a$edgePar, list(col=col, lwd=2)) n # Don't forget to return the node! } # Color the first sub-branch of the first branch in red, # the second sub-branch in orange and the second branch in blue hc[[1]][[1]] = dendrapply(hc[[1]][[1]], colbranches, "red") hc[[1]][[2]] = dendrapply(hc[[1]][[2]], colbranches, "orange") hc[[2]] = dendrapply(hc[[2]], colbranches, "blue") # Plot plot(hc)
에서 FigTree로 데이터를 가져 오려면 ,dm
library(ape) z <- as.phylo(hclust(as.dist(dm))) write.nexus(z, file="output.nex")
트렌드
- OpenCv의 폴더에서 여러 이미지 읽기 (python)
- 파이썬 셀레늄 모든 "href"속성 가져 오기
- html - 자바 스크립트 - 클릭 후 변경 버튼 텍스트 변경
- javascript - 현재 URL에서 특정 div 만 새로 고침/새로 고침
- JSP에 대한 클래스를 컴파일 할 수 없습니다
- JavaScript 변수를 HTML div에 '출력'하는 방법
- git commit - 자식 - 로컬 커밋 된 파일에 대한 변경을 취소하는 방법
- jquery - JavaScript로 현재 세션 값을 얻으시겠습니까?
- javascript - swiperjs에서 정지, 재생 버튼 추가
- python - 화면에서 찾은 요소를 찾을 수없는 경우 셀레늄
다음과 같은 작업을 위해 dendextend 패키지를 사용할 수 있습니다 :
패키지의 프리젠 테이션 및 비네팅에서 다음 URL의 "사용"섹션에 많은 예제가 있습니다. https://github.com/talgalili/dendextend