This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to adjust the size of the short line between two haplotypes?

When I try to plot the haplotype work by pegas packages , a liiter problem has been arisen.The short line between the two haplotypes is used to indicate the number of mutations, the length of the short line is too long, so I want to adjust the length of the short line, but I have not found a good way, I hope you can help me, thank you very much!

Here's the code:

library(pegas)
library(tidyverse)

setwd("D:/Rworkplace/haplotype/Os07g0423000/")

rm(list = ls())
y <- read.table("30.CSV", sep = ",", header = F)
names(y) <- c("SNPID", "Subgroup", "seq")
head(y)

a=as.data.frame(table(y$seq))
arrange(a,Freq)

x <- read.dna("30.txt", format = "fasta")

### 
h <- haplotype(x)
print(h, T)
attributes(h)
net <- haploNet(h)
snp_type <- stack(setNames(attr(h, "index"), rownames(h)))
result <- cbind(snp_type, y[snp_type[[1]],])

### 
ind.hap2<-with(
  stack(setNames(attr(h, "index"), rownames(h))), 
  table(hap=ind, pop=y[[2]][values])
)

par(bg="white")
par(mar=c(1,0,3,1),oma=c(0,0,0,0))
c1=c("#d2deec","#b4aacc","#edac98","#cfe3b3","#f4dbaf") 
plot(net, size=attr(net, "freq"), scale.ratio = 30, asp =1,
     pie=ind.hap2,
     bg=c1, 
     legend = F,  fast = F, show.mutation = 1, threshold = c(2,3,3), 
     labels = F,
     col.link = "black", cex = 2, lwd = 1, lty = 1, font=1)

legend(1300,1050, colnames(ind.hap2), 
       col=c1, 
       pch=15, 
       cex = 1, border ="white", box.col = "white",
       y.intersp=0.5,x.intersp = 0.5)

a <- as.data.frame(ind.hap2)
write.csv(result, "test_haplotype_result1.csv", row.names = F)
write.csv(spread(a, pop, Freq), "test_haplotype_result2.csv", row.names = F)

The relevant data can be obtained at the following link

line:https://pan.baidu.com/s/1qOxfsbWKYiJg7lFrYPR7YQ

code:yvni

picture

pegas r

0 answers

No answers yet.

Log in to answer this question.