R语言 在绘制3轴3d散射图时,错误需要有限xlim

ca1c2owp  于 2023-07-31  发布在  其他
关注(0)|答案(1)|浏览(89)

我试图绘制3轴散点图。我用的包:

library(scatterplot3d)

字符串
这是我的dataframe:

dput(gene)
structure(list(rsid = c("geneid1", "geneid2", "geneid3", "geneid4", 
"geneid5", "geneid6", "geneid7", "geneid8", "geneid9", "geneid10", 
"geneid11", "geneid12", "geneid13", "geneid14", "geneid15", "geneid16", 
"geneid17", "geneid18", "geneid19", "geneid20", "geneid21", "geneid22", 
"geneid23", "geneid24", "geneid25", "geneid26", "geneid27", "geneid28", 
"geneid29", "geneid30", "geneid31", "geneid32", "geneid33", "geneid34", 
"geneid35", "geneid36", "geneid37", "geneid38", "geneid39", "geneid40", 
"geneid41", "geneid42", "geneid43", "geneid44", "geneid45", "geneid46", 
"geneid47", "geneid48", "geneid49", "geneid50", "geneid51", "geneid52", 
"geneid53", "geneid54", "geneid55", "geneid56", "geneid57", "geneid58", 
"geneid59", "geneid60", "geneid61", "geneid62", "geneid63", "geneid64", 
"geneid65", "geneid66", "geneid67", "geneid68", "geneid69", "geneid70", 
"geneid71", "geneid72", "geneid73", "geneid74", "geneid75", "geneid76", 
"geneid77", "geneid78", "geneid79", "geneid80", "geneid81", "geneid82", 
"geneid83", "geneid84", "geneid85", "geneid86", "geneid87", "geneid88", 
"geneid89", "geneid90", "geneid91", "geneid92", "geneid93", "geneid94", 
"geneid95", "geneid96", "geneid97", "geneid98", "geneid99", "geneid100", 
"geneid101", "geneid102", "geneid103", "geneid104", "geneid105", 
"geneid106", "geneid107", "geneid108", "geneid109", "geneid110", 
"geneid111", "geneid112", "geneid113", "geneid114", "geneid115", 
"geneid116", "geneid117", "geneid118", "geneid119", "geneid120", 
"geneid121", "geneid122", "geneid123", "geneid124", "geneid125", 
"geneid126", "geneid127", "geneid128"), empiricalpvalue = c(6.13461252366445e-122, 
1.16535620114822e-84, 8.70333130656012e-95, 6.21764431355086e-78, 
1.3419299160444e-104, 2.1205949537435e-87, 8.88049533513058e-82, 
2.37291630796694e-59, 6.89525879641339e-87, 9.15023133356126e-110, 
3.38640359272591e-95, 6.46902643155203e-97, 4.03813386099403e-68, 
9.02172515192496e-79, 1.49057561236869e-76, 3.75651498115438e-71, 
1.21242518225615e-92, 3.80900176762236e-112, 3.19156461606367e-90, 
3.12205363999601e-112, 3.75219679463562e-76, 5.79336944438183e-102, 
1.16088756611029e-92, 4.79478718145423e-71, 4.46873500738817e-68, 
3.61567839124827e-90, 2.73461291112396e-50, 5.31076204704237e-82, 
4.78173518650222e-71, 1.47603869715026e-76, 5.31076204704237e-82, 
1.34296126323826e-104, 1.47603869715026e-76, 4.78173518650222e-71, 
4.18664557737661e-102, 1.23726835252678e-47, 1.81409531313344e-87, 
1.81409531313344e-87, 9.17728799649733e-77, 1.14037287289173e-84, 
6.85171121323749e-115, 9.64380530301843e-85, 1.88308874461263e-97, 
4.54315679209976e-84, 1.15617930948075e-57, 2.61302778878597e-87, 
1.59617378477945e-107, 6.67041379381125e-97, 2.91012034679369e-73, 
6.42709856844799e-70, 4.77978670784383e-71, 3.73579797895449e-90, 
2.54822788576734e-84, 5.32401346280141e-82, 1.86531289438543e-87, 
1.27417263340724e-84, 8.47051451192377e-87, 1.67865103963281e-99, 
1.65173041055351e-87, 1.60318019118551e-92, 1.68953511584346e-97, 
1.61821544439548e-87, 1.64030885809042e-76, 2.58826953869118e-94, 
4.15415840174316e-102, 3.66836413482857e-90, 9.75351878266387e-85, 
2.15813794646134e-87, 5.20166809636258e-98, 1.45040537115182e-92, 
3.92026467069203e-76, 7.02257254289247e-80, 7.88167077050651e-100, 
5.98528923250908e-89, 2.6123159641609e-65, 4.58668502343678e-72, 
3.3269638981147e-65, 3.93215270864855e-88, 4.94770292217309e-90, 
2.61051540730913e-93, 4.82058308970484e-65, 4.03813386099403e-68, 
4.9040562801298e-68, 1.64625360058074e-97, 1.18180478789365e-67, 
2.37606653980273e-95, 6.68678557257316e-115, 2.83305168489427e-76, 
4.47438785926932e-84, 7.83381751772824e-100, 2.56336302630105e-62, 
1.6645346622893e-97, 1.49294643386617e-92, 1.30971986837447e-76, 
2.68991872345451e-62, 4.63183258997433e-71, 1.88138224471355e-97, 
1.81344406130667e-38, 4.50067096666545e-95, 1.28960110233455e-87, 
8.39303827966421e-74, 1.75361636514329e-50, 4.36558718606554e-95, 
4.23200952395284e-82, 1.77477358560346e-79, 4.4667933690595e-79, 
7.00055719563781e-82, 1.31125522310481e-87, 2.7358859862243e-56, 
7.98709105347624e-100, 1.15689932217416e-83, 3.17870997682453e-90, 
2.5665694961431e-62, 1.06323967424683e-84, 4.9588998029082e-95, 
1.73555014818939e-112, 4.76922555104304e-82, 1.29059454331569e-87, 
2.88582096884338e-92, 7.486055585569e-85, 4.43940003277464e-67, 
8.11453165153395e-107, 3.79101954373641e-76, 2.067304055207e-101, 
3.147003601088e-75, 2.3221340846221e-114, 7.49267907095058e-105, 
2.84518694290315e-52), pvalue = c(0.68588704183079, 0.68588704183079, 
0.220127260333427, 0.69423733480229, 0.490693614490964, 0.549166912433013, 
0.321119909131389, 0.470400199588203, 0.11068697727484, 0.492304167343793, 
0.977843368740407, 0.773842773679014, 0.0274086629991561, 0.0345100898198675, 
0.156009865827704, 0.177229984361821, 0.00334568549642378, 0.0246216153164539, 
0.00070484993149725, 0.00339864494961824, 0.00095625626066833, 
0.542502183036992, 0.0115397045957251, 0.0115397045957251, 0.318141606666907, 
0.00764434227225787, 0.00088342793282982, 0.00764434227225787, 
0.00764434227225787, 0.00764434227225787, 0.00764434227225787, 
0.00764434227225787, 0.00764434227225787, 0.00764434227225787, 
0.00764434227225787, 0.00764434227225787, 0.00764434227225787, 
0.00764434227225787, 0.227553616807578, 0.00307816889794103, 
0.810397696543416, 0.00481535382790678, 0.00481535382790678, 
0.567426075472232, 0.0709536216660615, 0.388300338453881, 0.723454085678846, 
0.17440795565029, 0.566179572879549, 0.0956525104821812, 0.104465873612382, 
0.702561306710734, 0.0976196418847593, 0.106833472632844, 0.106833472632844, 
0.399547088387142, 0.859507690578278, 0.0896054864434418, 0.0197881057481875, 
0.674477409919487, 0.893368122468456, 0.259198799140294, 0.0078277208585352, 
0.00660445466557924, 8.93935575744768e-07, 8.93935575744768e-07, 
0.0215191532899952, 0.00089969281273726, 1.71318094466417e-11, 
1.93744902020634e-06, 0.196919576816204, 0.00026308488486724, 
0.188048768850889, 3.37730930462203e-06, 1.71497115213503e-06, 
1.95606081221237e-09, 0.0215191532899952, 0.344393628448912, 
1.10524547799898e-06, 0.0002118690694374, 0.230805625978978, 
0.312040934992537, 0.950614873380497, 0.973950437945092, 0.154323417882195, 
0.78229924581066, 0.0197898099613507, 0.126150764855425, 0.0140779029458078, 
0.0451687447107746, 0.0451687447107746, 0.32952913111269, 0.933231564503113, 
0.318911210914388, 0.0508011296179234, 0.0435980949615047, 0.0435980949615047, 
0.0150579714577512, 0.0788408082086297, 0.0697326429444134, 0.355093197783839, 
0.191699208310582, 0.355093197783839, 0.107475347310097, 0.319442636540046, 
0.499040970288875, 0.289895623821287, 0.289895623821287, 0.0715147992163933, 
0.0823680777596502, 0.0435914001980873, 0.238698857794745, 0.238698857794745, 
0.238698857794745, 0.238698857794745, 0.032954479808064, 0.14377893219712, 
0.0957562786854422, 0.0957562786854422, 0.0957562786854422, 0.382084461781353, 
0.2559848955185, 0.183032024396735, 0.0344081978664664, 0.383607993152143, 
0.269176925197184, 0.0809293638661076, 0.0648895903300949), maxR2 = c(1, 
1, 0.24646074832345, 0.318529494648516, 0.537361473230975, 0.487775682828868, 
0.487775682828868, 0.537361473230975, 0.318529494648516, 0.195526010871951, 
0.144411290687557, 0.42495871885722, 0.42495871885722, 0.688343016856399, 
0.852092352092352, 0.688343016856399, 0.822846645483939, 0.822846645483939, 
0.92467673120711, 0.92467673120711, 0.133336040413401, 0.241614449882966, 
1, 1, 0.222225540135554, 1, 0.338767571798379, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 0.852092352092352, 0.81589109807783, 0.247206550359501, 
1, 1, 0.298914213604681, 0.269548068682413, 0.359274829666961, 
0.597926514989907, 0.597926514989907, 0.359274829666961, 0.14706412437914, 
0.365428598598603, 0.385, 0.520124160669906, 1, 1, 0.239520969186289, 
0.118172253993026, 0.246651718484139, 0.203669029422643, 0.239822084968639, 
0.224561807135871, 0.219837685176587, 0.355308267456096, 0.352300297299731, 
1, 1, 1, 0.69144988013248, 0.870624894382649, 0.71474839040327, 
0.126707938714564, 0.68463075898378, 0.239822084968639, 0.971008312455224, 
0.971008312455224, 0.870624894382649, 1, 0.173965505954282, 0.634715421497106, 
0.663625095509327, 0.173154748259788, 0.777646647937935, 0.777646647937935, 
0.494829318691275, 0.669948731345372, 0.286608298357456, 0.669948731345372, 
0.257854250390985, 0.239520969186289, 1, 1, 0.191448862824438, 
0.184880399183239, 0.160153297583809, 0.98254847816179, 1, 1, 
0.940413080805106, 0.571737457140003, 0.940413080805106, 1, 0.162156384275673, 
1, 0.243533199479121, 0.155160539315454, 0.671263122385402, 1, 
1, 0.205198409129552, 0.210437753515572, 0.189411423519086, 1, 
1, 1, 1, 0.296376406781993, 0.923490988913509, 1, 1, 1, 0.241614449882966, 
0.169138820306718, 0.148054212558727, 0.223841261627209, 0.167433583712982, 
0.262610336629144, 0.385, 0.20449643660452)), row.names = c(NA, 
-128L), class = c("tbl_df", "tbl", "data.frame"))


当我运行这段代码时,它给了我一个错误:

scatterplot3d(gene$pvalue,gene$empiricalpvalue, gene$maxR2)
Error in plot.window(c(x1, x2), c(z.min, z.max + yz.f * y.max), asp = asp) : 
  need finite 'xlim' values


我在谷歌检查了这个特定的错误,它对应于在dataframe中有NA值,但在我的情况下,我没有任何NA值。我添加了整个数据集以供参考。有没有办法解决这个问题或任何其他软件包绘制三维散点图。- 谢谢-谢谢

abithluo

abithluo1#

你所有的经验p值都很小:

range(gene$empiricalpvalue)
#> [1] 6.134613e-122  1.813444e-38

字符串
scatterplot3D中的代码接受这个范围,将其转换为一个漂亮的断点序列,然后将前两个断点之间的差值作为y轴的缩放因子。不幸的是,它将这个比例因子四舍五入到小数点后12位。这一切都发生在线路中:

y.prty <- pretty(y.range, n = lab[2], 
                 min.n = max(1, min(0.5 * lab[2], p.lab[2])))
y.scal <- round(diff(y.prty[1:2]), digits = 12)


由于比例因子约为10^-39,因此将其四舍五入到小数点后12位,将其四舍五入为0。当y值被缩放以进行打印时,它们因此被除以0。这使得它们都是Inf,因此当较低级别的图形函数试图绘制它们时,没有有限值可供绘制。
如果你取p值的对数,这个问题就消失了:

scatterplot3d(log10(gene$pvalue), log10(gene$empiricalpvalue), gene$maxR2)


x1c 0d1x的数据

相关问题