Seurat dotPlot code issue: Error in `levels<-`(`*tmp*`, value = as.character(levels))
1
0
Entering edit mode
2.0 years ago
Andy ▴ 120

Good afternoon,

I meet a problem when drawing my DotPlot, the error is:

Error in `levels<-`(`*tmp*`, value = as.character(levels)) : 
      factor level [36] is duplicated

My code is:

> pdf(file='celltype_markergene_dotplot.pdf',width=20)
>DotPlot(data, features =c("DCN", "COL1A2", "CFD",
                          "KLRB1", "CD7", "GZMK", 
                          "MT1G", "MT1H", "MT1F", 
                          "HSPA1A", "HSPA6", "DNAJB1",
                          "CCL5", "CD3E", "CXCR4", 
                          "IFI27", "TM4SF1", "CLDN5",
                          "HLA-DRA", "HLA-DPB1", "HLA-DQB1",
                          "S100A9", "S100A8", "LST1", 
                          "GNLY", "GZMB", "FGFBP2", 
                          "S100A2", "SFN", "KRT14", 
                          "CCL4", "CCL3", "NKG7", 
                          "ALDOB", "PCK1", "MT1G", 
                          "S100A8", "S100A9", "FCGR3B", 
                          "PRSS1", "CLPS", "PNLIP",
                          "SFTPC", "CXCL2", "SFTPA1", 
                          "HSPA6", "HSPA1A", "IFNG", 
                          "TAGLN", "ACTA2", "MYL9", 
                          "MT1G", "MT1H", "MT1F", 
                          "CD79A", "IGKC", "IGHM", 
                          "KRT1", "DMKN", "LGALS7B",
                          "LGALS1", "COL6A2", "ZFP36L1", 
                          "PRSS1", "CLPS", "CPA1", 
                          "MT2A", "MT1X", "SLC30A1", 
                          "TRAC", "CD52", "RPL27A", 
                         "IGFBP7", "SPARCL1", "A2M", 
                          "DCT", "TYRP1", "MLANA"))+ theme(axis.text.x = element_text(angle = 90))
>dev.off()

I have no idea where my code is wrong. Please help me out.

Thank you very much

seurat R • 1.9k views
ADD COMMENT
2
Entering edit mode
2.0 years ago

some of your feature labels are duplicated, hence the tool is unable to use them, make the features unique

x = c("DCN", "COL1A2", "CFD",
  "KLRB1", "CD7", "GZMK", 
  "MT1G", "MT1H", "MT1F", 
  "HSPA1A", "HSPA6", "DNAJB1",
  "CCL5", "CD3E", "CXCR4", 
  "IFI27", "TM4SF1", "CLDN5",
  "HLA-DRA", "HLA-DPB1", "HLA-DQB1",
  "S100A9", "S100A8", "LST1", 
  "GNLY", "GZMB", "FGFBP2", 
  "S100A2", "SFN", "KRT14", 
  "CCL4", "CCL3", "NKG7", 
  "ALDOB", "PCK1", "MT1G", 
  "S100A8", "S100A9", "FCGR3B", 
  "PRSS1", "CLPS", "PNLIP",
  "SFTPC", "CXCL2", "SFTPA1", 
  "HSPA6", "HSPA1A", "IFNG", 
  "TAGLN", "ACTA2", "MYL9", 
  "MT1G", "MT1H", "MT1F", 
  "CD79A", "IGKC", "IGHM", 
  "KRT1", "DMKN", "LGALS7B",
  "LGALS1", "COL6A2", "ZFP36L1", 
  "PRSS1", "CLPS", "CPA1", 
  "MT2A", "MT1X", "SLC30A1", 
  "TRAC", "CD52", "RPL27A", 
  "IGFBP7", "SPARCL1", "A2M", 
  "DCT", "TYRP1", "MLANA")

x[duplicated(x)]

prints:

"MT1G"   "S100A8" "S100A9" "HSPA6"  "HSPA1A" "MT1G"   "MT1H"   "MT1F"   "PRSS1"  "CLPS" 
ADD COMMENT
0
Entering edit mode

Really thanks for your reply.

If I understand you right, for the markers like S100A8 and S100A9 are considered to be duplicated? Since I want to draw a bubble plot for the expression of my markers in different clusters, and S100A8 and S100A9 are markers for one of my clusters. In this case, could you please give me some suggestions? Maybe I should only use one marker per cluster?

If so, what if I want to draw a graph that show the expression level for my top 3 markers in each cluster, do you have any suggestions how to do it?

Thanks for your help.

ADD REPLY

Login before adding your answer.

Traffic: 1550 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6