0

I used the R package circlize to draw a PDF image (Figure 1)fig.1. The display of images viewed through R studio zoom and WPS(a type of PDF reader) is shown in Figure 1. However, when I opened the PDF through AI, a large number of redundant lines appeared, as shown in Figure 2fig.2. The details of redundant lines were shown in Figure 3fig3. What is the reason? How to solve it?

The body code of my drawing is as follows (some coloring related code or data are not shown):

library(circlize) 
library(reshape2)
library(ComplexHeatmap) 
library(grid)
library(dplyr)
library(tidyr)

gap_size <- c(rep(0.8, length(all_otu) - 1), 6, rep(0.8, length(all_sample) - 1), 6)
circos.par(cell.padding = c(0, 0, 0, 0), start.degree = 270, gap.degree = gap_size)
circos.initialize(factors = factor(all_ID, levels = all_ID), xlim = all_ID_xlim)

circos.trackPlotRegion(
    ylim = c(0, 1), track.height = 0.03, 
    bg.border = NA, 
    panel.fun = function(x, y) {
        sector.index = get.cell.meta.data('sector.index')
        xlim = get.cell.meta.data('xlim')
        ylim = get.cell.meta.data('ylim')
    } )

for (i in 1:length(tax_phylum)) {
    tax_OTU <- {subset(taxonomy, phylum == tax_phylum[i])}$OTU_ID
    highlight.sector(tax_OTU, track.index = 1, col = color_otu[i], 
                     text = tax_phylum[i], 
                     facing = "clockwise",cex = 0.5, text.col = 'black', niceFacing = T)
}

for (i in 1:length(all_group)) {
    group_sample <- {subset(group, group_ID == all_group[i])}$sample_ID
    highlight.sector(group_sample, track.index = 1, col = color_sample[i], 
                     text = all_group[i], 
                     facing = "clockwise",cex = 0.7, text.col = 'black',niceFacing = T)
}

link_color <- character(nrow(plot_data))
for (i in seq_len(nrow(plot_data))) {
  group_index <- match(plot_data[i,1], group[,1])
  color_index <- group[group_index, 2]
  link_color[i] <- color_sample[color_index]

    circos.link(
      plot_data[i,1], c(accum_sample[as.character(plot_data[i,1])], accum_sample[as.character(plot_data[i,1])] - plot_data[i,4]),
      plot_data[i,2], c(accum_otu[as.character(plot_data[i,2])], accum_otu[as.character(plot_data[i,2])] - plot_data[i,3]),
      #col = paste0(color_otu[plot_data[i,2]], '70'), border = NA )
        col = paste0(link_color[i], '75'), border = NA )
    accum_otu[as.character(plot_data[i,2])] = accum_otu[as.character(plot_data[i,2])] - plot_data[i,4]
    accum_sample[as.character(plot_data[i,1])] = accum_sample[as.character(plot_data[i,1])] - plot_data[i,3]
}

all_ID,chr[1:156]

> all_ID
  [1] "hg_bin.256"                                                
  [2] "fg_bin.37"                                                 
  [3] "hg_bin.189"                                                
  [4] "hg_bin.230"                                                
  [5] "hg_bin.257"   

all_ID_xlim,156 obs. of 2 variables

> all_ID_xlim                                                        rep(0, length(all_ID))
hg_bin.256                                                                      0
fg_bin.37                                                                       0
hg_bin.189                                                                      0
hg_bin.230                                                                      0
hg_bin.257                                                                      0
hg_bin.258                                                                      0
hg_bin.112                                                                      0

plot_data,6075 obs. of 4 variables

> head(plot_data)
                    sample_ID     otu_ID value value.1
1   aminoglycoside__aac(2')-I hg_bin.256     0       0
82   aminoglycoside__aac(3)-I hg_bin.256     0       0
163          bacitracin__bacA hg_bin.256     1       1
244         beta-lactam__ampC hg_bin.256     0       0
325        beta-lactam__CfxA2 hg_bin.256     0       0
406        beta-lactam__CfxA3 hg_bin.256     0       0
                                                    

tax_phylum

> tax_phylum
 [1] p__Firmicutes_A     p__Bacteroidota     p__Proteobacteria  
 [4] other               p__Actinobacteriota p__Firmicutes      
 [7] p__Planctomycetota  p__Cyanobacteria    p__Firmicutes_C    
[10] p__Fusobacteriota  
10 Levels: p__Firmicutes_A p__Bacteroidota p__Proteobacteria ... p__Fusobacteriota

all_group,chr[1:16]

> head(all_group)
[1] "aminoglycoside"  "bacitracin"      "beta-lactam"    
[4] "chloramphenicol" "fosfomycin"      "fosmidomycin" 

group,75 obs. of 2 variables

> head(group)
                  sample_ID       group_ID
1 aminoglycoside__aac(2')-I aminoglycoside
2  aminoglycoside__aac(3)-I aminoglycoside
3          bacitracin__bacA     bacitracin
4         beta-lactam__ampC    beta-lactam
5        beta-lactam__CfxA2    beta-lactam
6        beta-lactam__CfxA3    beta-lactam

taxonomy,81 obs. of 8 variables

> head(taxonomy)
       OTU_ID     kingdom          phylum         class
2  hg_bin.256 d__Bacteria p__Firmicutes_A c__Clostridia
4   fg_bin.37 d__Bacteria p__Firmicutes_A c__Clostridia
14 hg_bin.189 d__Bacteria p__Firmicutes_A c__Clostridia
16 hg_bin.230 d__Bacteria p__Firmicutes_A c__Clostridia
18 hg_bin.257 d__Bacteria p__Firmicutes_A c__Clostridia
19 hg_bin.258 d__Bacteria p__Firmicutes_A c__Clostridia
                order                family            genus
2   o__Lachnospirales    f__Lachnospiraceae g__Eubacterium_G
4   o__Lachnospirales    f__Lachnospiraceae g__Acetatifactor
14  o__Lachnospirales    f__Lachnospiraceae       g__CAG-510
16  o__Lachnospirales    f__Lachnospiraceae       g__Dorea_A
18  o__Lachnospirales    f__Lachnospiraceae g__Eubacterium_G
19 o__Oscillospirales f__Acutalibacteraceae g__Eubacterium_R
                         species
2   s__Eubacterium_G sp000434315
4  s__Acetatifactor intestinalis
14        s__CAG-510 sp000434615
16      s__Dorea_A longicatena_B
18   s__Eubacterium_G ventriosum
19  s__Eubacterium_R sp000434995

At the same time, I also tried to export the file in eps format using R studio and open it using AI. The AI suggested that I lacked Helvetica font and all lines were not displayed (see Figure 4)fig4. After I installed Helvetica font and opened it using AI, no font error was reported, but the image preview was still the same as that in Figure 4.

When I use the example data and the example code, there are no redundant lines, so I am more confident that it is my code error, or my own data overload?

  • 3
    Your use of "AI" in your question is unclear, and requires further details. Are you referring to Artificial Intelligence, or Adobe Illustrator? – mhovd Jun 11 '23 at 14:47

0 Answers0