Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plotCNA:增加CNV的绘图功能 #259

Open
qingjian1991 opened this issue Jan 7, 2022 · 1 comment
Open

plotCNA:增加CNV的绘图功能 #259

qingjian1991 opened this issue Jan 7, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@qingjian1991
Copy link

我对plotCNA的代码进行了修改,增加了3个函数参数。

对应的修改后的脚本在这个文件中。
plotCNA.txt

Type.name:指定用于绘图的列
Type.colors:指定对应的颜色
rect.patients.size:按照病人加一个长方形的框区分病人

我们在绘制CNV时,可能想自己定义CNV的类型和对应的颜色表示

# read data
segFile <- system.file("extdata", "CRC_HZ.seg.txt", package = "MesKit")
seg <- readSegment(segFile = segFile)

# define the new columns
# 0-6 copy numbers, add cnLOH, LOH >=2 copys
Copy_cutoff = function(seg){
  seg %>%
    mutate(CopyNumber1 = ifelse(CopyNumber >5, 6, CopyNumber) ) %>%
    mutate(CopyNumber1 = ifelse(CopyNumber == 2 & Minor_CN == 0, "cnLOH",  CopyNumber1)) 
}

seg1 = lapply(seg, Copy_cutoff)

用原始的程序绘图

#original plot
plotCNA(seg1,
         showRownames = FALSE)

image

重新定于拷贝数的情况及其颜色

plotCNA(seg1,
         Type.name = "CopyNumber1",
         Type.colors = setNames(
           c("#7D8BCD", "#B1B9E7", "#F6F7F7", "#E4A8B5", "#CB7185","#B03D5E","#99143C", "#91BAA7"), 
           nm = c(seq(0,6), "cnLOH")
         ),
         showRownames = FALSE,
         rect.patients.size = 0
         
)

image

绘制minor-copy的情况

#Plot Minor_CNVs
plotCNA(seg1,
         Type.name = "Minor_CN",
         Type.colors = setNames(
           c("#7D8BCD", "#F6F7F7", "#E4A8B5", "#CB7185","#B03D5E"), 
           nm = 0:4
         ),
         showRownames = FALSE,
         rect.patients.size = 0
)

image

绘制minor-copy的情况并对每一个病人加一个长方形的框表示病人

#Plot Minor_CNVs and add a rectangle to indicate the patients
plotCNA(seg1,
         Type.name = "Minor_CN",
         Type.colors = setNames(
           c("#7D8BCD", "#F6F7F7", "#E4A8B5", "#CB7185","#B03D5E"), 
           nm = 0:4
         ),
         showRownames = FALSE,
         rect.patients.size = 0.3
)

image

@likelet
Copy link
Collaborator

likelet commented Jan 8, 2022

@Niinleslie update the code accordingly, Many thanks for your improvement to our code @qingjian1991

@likelet likelet added the enhancement New feature or request label Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants