microbial_forensics
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| microbial_forensics [2021/10/05 11:19] – [분석과정(2) - distance matrix에서 확률 밀도 함수(pdf) 구하기] hyjeong | microbial_forensics [2021/10/05 12:42] (current) – [plot_pdfs_from_distance_matrix.R 코드의 수정판] hyjeong | ||
|---|---|---|---|
| Line 31: | Line 31: | ||
| 자, 그러면 selected_listeria_dist.csv 중에서 무엇을 배제하는 것이 좋을까요? | 자, 그러면 selected_listeria_dist.csv 중에서 무엇을 배제하는 것이 좋을까요? | ||
| + | |||
| + | ===== plot_pdfs_from_distance_matrix.R 코드의 수정판 ===== | ||
| + | 함수만 선언한 [[https:// | ||
| + | * 함수 선언 전까지의 9줄은 데이터 파일을 읽어서 처리하기 위한 것입니다. | ||
| + | * 함수의 default argument로 주어지는 lim 벡터는 원본(c(0.05, | ||
| + | * Plot 파일의 이름과 형식은 eps가 아닌 pdf로 수정하였습니다. | ||
| + | * ggplot()의 그림은 print() 함수를 실행하여 파일로 저장하도록 하였습니다. 원본 코드 그대로는 파일이 제대로 생기지 않았습니다. 아래의 코드를 사용하여 얻은 플롯을 첨부합니다({{ : | ||
| + | |||
| + | mat.org=read.table(" | ||
| + | dim(mat.org) # 148 x 148 | ||
| + | all = paste(scan(" | ||
| + | mat = mat.org[all, | ||
| + | mat = mat[, all] | ||
| + | dim(mat) # 111 x 111 | ||
| + | index0 = rownames(mat) | ||
| + | f1=paste(scan(" | ||
| + | index1 = which(index0 %in% f1) | ||
| | | ||
| + | plot_pdfs_from_distance_matrix< | ||
| + | | ||
| + | require(ggplot2) | ||
| + | nr< | ||
| + | ntot< | ||
| + | index.tot< | ||
| + | index2< | ||
| + | | ||
| + | df< | ||
| + | colnames(df)< | ||
| + | df$sample_j< | ||
| + | df$Type< | ||
| + | df$Value< | ||
| + | k<-1 | ||
| + | nr1< | ||
| + | for(i in 1:nr1){ | ||
| + | i1<-i+1 | ||
| + | for(j in i1:nr){ | ||
| + | if((i %in% index1 && j %in% index1) || (i %in% index2 && j %in% index2)){ | ||
| + | df[k, | ||
| + | df[k, | ||
| + | df[k, | ||
| + | df[k, | ||
| + | } | ||
| + | else{ | ||
| + | df[k, | ||
| + | df[k, | ||
| + | df[k, | ||
| + | } | ||
| + | k<-k+1 | ||
| + | } | ||
| + | } | ||
| + | | ||
| + | df2< | ||
| + | | ||
| + | if(is.null(filename)==FALSE){ | ||
| + | if(filetype==" | ||
| + | postscript(filename) | ||
| + | } | ||
| + | else{ | ||
| + | pdf(filename) | ||
| + | } | ||
| + | } | ||
| + | | ||
| + | p = ggplot(df2, | ||
| + | print(p) | ||
| + | | ||
| + | if(is.null(filename)==FALSE){ | ||
| + | dev.off() | ||
| + | } | ||
| + | return(df) | ||
| + | | ||
| + | } | ||
| + | | ||
| + | # 원본 R 코드는 바로 직전까지에 해당합니다. 실제 함수를 호출하기 위해 다음의 한 줄을 삽입했습니다. | ||
| + | dat = plot_pdfs_from_distance_matrix(mat, | ||
| + | | ||
| + | ===== 앞으로 해결할 문제 ===== | ||
| + | 위의 코드를 실행하여 얻어진 분포(dat 데이터프레임으로 반환됨)를 kernel density estimation으로 처리하여 연속형 확률 분포와 유사하게 만드는 것이 바로 다음에 진행해야 할 일입니다. 구체적인 코드는 제시하지 않았습니다. 다음으로는 8개의 clinical sample에 대하여 다음의 likelihood ratio(' | ||
| + | {{ :lr.png?200 |}} | ||
| + | 이 수식으로 표현된 evidential value를 구하는 방법은 논문 5쪽 왼쪽단에 다음과 같이 기술하였습니다. | ||
| + | To calculate evidential values, the genetic distances from | ||
| + | sequences associated with facility 1 were calculated for the | ||
| + | sequences obtained from each patient, and the densities under | ||
| + | Hm and Ha were compared according to Eq. (4). For each distance, | ||
| + | a likelihood ratio was obtained from the PDFs and the average | ||
| + | likelihood ratio for each patient were reported. All the calculated | ||
| + | evidential values were strongly supportive or contradictive, | ||
| + | depending on the origin of each isolate (Table 1), and the | ||
| + | assignments of clinical samples to their respective sources were | ||
| + | fully consistent with the findings of Chen et al. [29]. | ||
microbial_forensics.1633400373.txt.gz · Last modified: by hyjeong
