RGLab / openCyto

A package that provides data analysis pipeline for flow cytometry.
GNU Affero General Public License v3.0
77 stars 29 forks source link

gate_mindensity_2( ) unable to find valleys even if gate_range() or min/max specified #246

Open maximesunnen opened 1 year ago

maximesunnen commented 1 year ago
library(openCyto)
library(ggcyto)
#> Loading required package: ggplot2
#> Loading required package: flowCore
#> Loading required package: ncdfFlow
#> Loading required package: BH
#> Loading required package: flowWorkspace
#> As part of improvements to flowWorkspace, some behavior of
#> GatingSet objects has changed. For details, please read the section
#> titled "The cytoframe and cytoset classes" in the package vignette:
#> 
#>   vignette("flowWorkspace-Introduction", "flowWorkspace")

matrix <- matrix(c(17.1702575683594, 3604.7919921875, 4885.357421875, 3255.04663085938, 
                   5461.55712890625, 336.679504394531, 20.1738185882568, 57.9650382995605, 
                   10395.81640625, 3046.4130859375, 15.0239753723145, 36.7612495422363, 
                   3241.30859375, 63.2228126525879, 8053.177734375, 8428.623046875, 
                   29.3448581695557, 3647.14086914062, 30.0510349273682, 4562.94677734375, 
                   7710.4169921875, 50.1847648620605, 8064.9267578125, 35.1330337524414, 
                   6951.19140625, 58.7328872680664, 7004.82666015625, 4567.06640625, 
                   63.8580627441406, 1890.22082519531, 13072.3974609375, 2986.533203125, 
                   8930.966796875, 15.9675989151001, 5982.67529296875, 7193.5205078125, 
                   4095.54418945312, 2986.24951171875, 5685.44580078125, 8338.701171875, 
                   3061.89038085938, 40.2612915039062, 222.174133300781, 3855.7373046875, 
                   52.5284042358398, 2251.46533203125, 29.0272331237793, 7835.1201171875, 
                   3421.5283203125, 10526.462890625, 3978.02294921875, 38.8057670593262, 
                   2468.51440429688, 22.0333137512207, 47.5759201049805, 9934.9736328125, 
                   28.2532138824463, 3344.5859375, 7842.2744140625, 4296.31396484375, 
                   58.917911529541, 4394.85205078125, 5088.3017578125, 1658.24658203125, 
                   5135.42724609375, 9481.5224609375, 517.18310546875, 3410.8740234375, 
                   1755.68969726562, 9690.9853515625, 1420.72473144531, 3412.0458984375, 
                   4297.44921875, 64.4532241821289, 32.521110534668, 12196.5078125, 
                   32.9528312683105, 1798.54748535156, 3154.87451171875, 4614.1611328125, 
                   1167.5712890625, 1653.48217773438, 6613.888671875, 3038.42309570312, 
                   3128.181640625, 1767.64221191406, 2715.787109375, 57.7214202880859, 
                   3435.05688476562, 2477.0810546875, 21.0064277648926, 2583.87084960938, 
                   4615.37646484375, 2290.48388671875, 6047.71142578125, 2472.37524414062, 
                   6717.36962890625, 5122.24755859375, 4787.87158203125, 25.286657333374, 
                   5060.20556640625, 3892.27661132812, 66.516242980957, 3321.20825195312, 
                   44.8714828491211, 3689.89379882812, 2648.66015625, 1972.36242675781, 
                   5279.36669921875, 62.8219261169434, 24.7870922088623, 4264.986328125, 
                   30.2884826660156, 5409.83349609375, 203.122787475586, 5323.36572265625, 
                   9053.7705078125, 751.698303222656, 81.3243560791016, 2468.57592773438, 
                   4997.1923828125, 5145.71142578125, 3344.4658203125, 2443.11059570312, 
                   3248.49047851562, 2162.04614257812, 4858.40576171875, 5395.978515625, 
                   3847.59008789062, 19.9332866668701, 2420.15209960938, 1096.36169433594, 
                   3949.1220703125, 22.5729675292969, 4100.345703125, 21.1883697509766, 
                   5509.19189453125, 24.1210041046143, 3338.53881835938, 37.1158790588379, 
                   30.0942058563232, 6838.384765625, 2440.9765625, 4414.45849609375, 
                   4685.962890625, 17.2257652282715, 4027.25805664062, 3755.97534179688, 
                   277.225036621094, 1675.69128417969, 7612.15380859375, 2775.802734375, 
                   1846.89428710938, 22.2522583007812, 5276.81689453125, 64.5179824829102, 
                   2927.88037109375, 4755.865234375, 4459.42236328125, 29.8567581176758, 
                   9103.767578125, 4047.41333007812, 47.8657913208008, 7190.9921875, 
                   22.5112934112549, 4613.24560546875, 43.2525215148926, 3079.779296875, 
                   5731.0576171875, 53.2746696472168, 6594.28564453125, 3481.2080078125, 
                   2237.68115234375, 43.5763130187988, 179.559936523438, 4162.1748046875, 
                   22.3015995025635, 5160.1064453125, 3272.40185546875, 6567.521484375, 
                   5204.82080078125, 12507.65625, 35.2594680786133, 23.3253993988037, 
                   14.3702230453491, 4083.06127929688, 4436.3623046875, 9326.234375, 
                   73.8308715820312, 1924.19128417969, 1236.00561523438, 3377.40307617188, 
                   3460.14916992188, 3960.70458984375, 3752.0712890625, 2421.49975585938, 
                   34.2387504577637, 43.4313774108887, 5627.357421875, 880.132934570312, 
                   26.4923992156982, 4477.54541015625, 3555.4150390625, 5462.26953125, 
                   4684.556640625, 8273.1318359375, 72.4061889648438, 5493.353515625, 
                   51.331916809082, 6619.0107421875, 2114.72924804688, 7633.9677734375, 
                   115.840644836426, 2844.87548828125, 5103.77587890625, 6616.02587890625, 
                   86.6468887329102, 3632.6103515625, 5748.3388671875, 4953.5234375, 
                   3615.79467773438, 17.4262084960938, 149.360885620117, 5003.47705078125, 
                   4457.10009765625, 2617.224609375, 21.9315490722656, 1760.80871582031, 
                   2625.6494140625, 3818.19287109375, 5807.44775390625, 1975.07299804688, 
                   3516.09130859375, 5180.3046875, 35.5986785888672, 33.6775093078613, 
                   6287.9189453125, 6149.005859375, 64.9743728637695, 21.7218551635742, 
                   6254.26611328125, 2170.326171875, 3754.80346679688, 7951.9013671875, 
                   4066.79760742188, 2609.33642578125, 84.1428985595703, 8174.29443359375, 
                   8498.6728515625, 7854.5849609375, 3220.3916015625, 9785.8994140625, 
                   39.6568794250488, 1532.63049316406, 113.126953125, 28.9439716339111, 
                   60.3364334106445, 3781.22192382812, 21.1791172027588, 2121.6923828125, 
                   4421.294921875, 23.4425811767578, 1576.10815429688, 3528.60815429688, 
                   20.3773460388184, 5930.73583984375, 32.1448936462402, 18.783052444458, 
                   6723.01904296875, 31.1241760253906, 1638.90539550781, 3548.48583984375, 
                   3654.00537109375, 2831.70776367188, 35.6048469543457, 40.7331047058105, 
                   2953.23193359375, 7189.2587890625, 70.0563735961914, 337.576873779297, 
                   3792.49291992188, 3231.29248046875, 567.01318359375, 6990.55224609375, 
                   10170.931640625, 8740.5859375, 1244.52294921875, 55.1403312683105, 
                   5126.345703125, 13.223072052002, 2907.71899414062, 4078.51586914062, 
                   43.1476707458496, 2622.57177734375, 1673.14416503906, 61.6439361572266, 
                   41.8247489929199, 80.8772125244141, 1766.44885253906, 3443.79614257812, 
                   2499.70947265625, 5784.70849609375, 28.3673133850098, 3392.82177734375, 
                   4462.39794921875, 30.3809947967529, 50.3697891235352, 4478.1591796875, 
                   3338.64379882812, 4754.76416015625, 3229.83715820312, 2123.24047851562, 
                   768.834655761719, 1635.60888671875, 5005.07470703125, 974.655700683594, 
                   19.6865882873535, 18.2372303009033, 2639.0390625, 5011.9326171875, 
                   753.036682128906, 26.3474636077881, 3529.357421875, 22.2152538299561, 
                   8040.05029296875, 3721.13818359375, 2621.79467773438, 4668.8515625, 
                   15540.55078125, 4732.4287109375, 5671.4580078125, 4024.15869140625, 
                   5315.33544921875, 4452.9462890625, 6572.5263671875, 795.536743164062, 
                   27.8584957122803, 3693.3076171875, 33.039176940918, 2137.18823242188, 
                   1800.53332519531, 28.1206130981445, 49.9133949279785, 9026.2392578125, 
                   4436.4267578125, 75.2493896484375, 5027.53662109375, 2664.61547851562, 
                   31.0779190063477, 6756.1044921875, 8640.48828125, 4028.47900390625, 
                   31.6268253326416, 4466.86328125, 9081.453125, 5640.63916015625, 
                   5364.53076171875, 7347.4794921875, 7512.8974609375, 12.0080785751343, 
                   3827.607421875, 3238.14770507812, 73.6211776733398, 5473.94482421875, 
                   218.803604125977, 6136.732421875, 2162.48413085938, 5363.0224609375, 
                   1837.99462890625, 20192.201171875, 4687.017578125, 43.7551689147949, 
                   1312.20483398438, 4820.9443359375, 3927.36938476562, 7292.8447265625, 
                   5237.033203125, 9692.0830078125, 13607.8916015625, 3778.01489257812, 
                   2288.71997070312, 6646.24658203125, 122.948661804199, 36.0242347717285, 
                   4931.9775390625, 22.3416881561279, 63.401668548584, 2906.10302734375, 
                   3118.9736328125, 24.6637420654297, 4907.400390625, 13295.7119140625, 
                   57.0584182739258, 2278.29711914062, 8515.2978515625, 2911.08032226562, 
                   1199.25671386719, 44.7974739074707, 3177.42578125, 3195.95288085938, 
                   6818.29150390625, 71.2035293579102, 8584.5947265625, 22.933765411377, 
                   4833.52294921875, 40.2119522094727, 3457.31518554688, 4427.05224609375, 
                   7391.51806640625, 75.8168029785156, 46.0032157897949, 2735.60302734375, 
                   62.2175140380859, 3469.76416015625, 4475.7353515625, 5653.076171875, 
                   3380.24633789062, 4614.759765625, 27.1461524963379, 34.6519737243652, 
                   8122.72216796875, 23.3192329406738, 2887.6376953125, 2154.38623046875, 
                   3788.5673828125, 95.4417114257812, 3805.21337890625, 711.618957519531, 
                   531.3466796875, 4313.5830078125, 4263.81787109375, 15672.00390625, 
                   1691.09155273438, 68.4281616210938, 20.1183109283447, 4506.10107421875, 
                   4040.1943359375, 31.762508392334, 4905.12109375, 677.685485839844, 
                   4320.13623046875, 7641.84375, 2910.61157226562, 16.9482288360596, 
                   5731.171875, 10.8979330062866, 4118.5830078125, 393.263031005859, 
                   4708.5419921875, 1828.29931640625, 3762.50048828125, 40.3106346130371, 
                   22.2152538299561, 22.431116104126, 2853.78442382812, 4624.2021484375, 
                   1611.52172851562, 2072.53759765625, 21.4998264312744, 30.2453098297119, 
                   24.0747489929199, 2420.96923828125, 3161.4921875, 11499.783203125, 
                   16.8094596862793, 2546.20288085938, 25.3390808105469, 5358.00830078125, 
                   5241.2763671875, 2396.45361328125, 5728.49169921875, 4074.658203125, 
                   1557.80615234375, 2942.51586914062, 42.1516265869141, 23.7941284179688, 
                   7506.14697265625, 92.7465286254883, 5991.2294921875, 29.7210731506348, 
                   1692.40209960938, 19.618745803833, 161.998046875, 3729.27319335938, 
                   34.0198059082031, 31.9105281829834, 6214.19287109375, 3434.7607421875, 
                   4955.765625, 2209.89672851562, 54.0363540649414, 2406.56811523438, 
                   32.3977584838867, 35.8638801574707, 4483.81787109375, 5078.529296875, 
                   3938.29516601562, 17.1332530975342, 2112.52758789062, 2562.71948242188, 
                   3251.93505859375, 3793.26391601562, 1699.36828613281, 8076.98388671875, 
                   40.908878326416, 18.0707092285156, 31.8396034240723, 42.0190238952637, 
                   62.6615715026855, 111.902709960938, 34.2048301696777, 3809.22534179688, 
                   6258.99072265625, 18.280403137207, 7505.3115234375, 4451.3828125, 
                   153.819976806641, 6334.6162109375, 18.3451614379883, 7118.4130859375, 
                   5004.5009765625, 1541.44384765625, 23.8527183532715, 35.7035255432129, 
                   5187.26171875, 5983.12548828125, 47.6684341430664, 6436.92236328125, 
                   6100.171875, 3436.03442382812, 68.4836730957031, 15.9521808624268, 
                   48.9327659606934, 569.541870117188, 1307.49291992188, 20.4482707977295, 
                   4761.314453125, 4870.08984375, 2121.60913085938, 2427.42651367188, 
                   4767.201171875, 3306.8349609375, 194.818283081055, 1488.07043457031, 
                   4338.92236328125, 857.744995117188, 4309.5341796875, 7198.59326171875, 
                   2123.37622070312, 7387.478515625, 2576.8955078125, 4582.173828125, 
                   3427.21801757812, 4432.7880859375, 31.0594158172607, 20.51611328125, 
                   64.1417694091797, 24.9474468231201, 2547.4951171875, 2830.03344726562, 
                   4888.92236328125, 4259.1396484375, 42.0776138305664, 7927.43505859375, 
                   4126.80126953125, 58.6403770446777, 18.7059593200684, 1276.11584472656, 
                   8269.0576171875, 4829.150390625, 5049.23388671875, 8782.1982421875, 
                   6742.07666015625, 18.2989063262939, 5073.447265625, 4816.5595703125, 
                   8984.876953125, 1166.37487792969, 4.23705720901489, 3184.6787109375, 
                   4351.98486328125, 28.4536571502686, 57.2249412536621, 2713.54516601562, 
                   7069.30126953125, 76.0203247070312, 5065.8486328125, 915.047058105469, 
                   5671.1865234375, 1777.08459472656, 8692.322265625, 455.755004882812, 
                   96.4963531494141, 8110.70458984375, 3383.73095703125, 7178.740234375, 
                   6222.978515625, 5087.4443359375, 143.652893066406, 2428.12670898438, 
                   3517.23852539062, 9.84329414367676, 33.162525177002, 2799.2978515625, 
                   4753.3798828125, 42.8948059082031, 2955.4521484375, 1849.2841796875, 
                   50.4222106933594, 34.7814903259277, 1749.83361816406, 21.5183296203613, 
                   4535.6865234375, 28.0342693328857, 4530.6044921875, 1612.76147460938, 
                   3218.43017578125, 6950.50048828125, 2380.68017578125, 3227.25903320312, 
                   6653.021484375, 694.081726074219, 4316.33984375, 4374.25244140625, 
                   247.414520263672, 3912.97143554688, 715.498291015625, 6150.69580078125, 
                   6002.041015625, 6714.8134765625, 66.0382690429688, 2055.25024414062, 
                   6418.70947265625, 3961.96606445312, 20.5346164703369, 4715.1474609375, 
                   4097.9619140625, 5688.18408203125, 4863.3828125, 11171.265625, 
                   3755.12426757812, 13068.5830078125, 2308.14135742188, 5246.18896484375, 
                   30.4920082092285, 3969.17260742188, 3424.54736328125, 2421.89135742188, 
                   1867.58312988281, 3242.13818359375, 24.9813671112061, 124.515205383301, 
                   4682.5400390625, 4707.6630859375, 85.5274963378906, 25.4285106658936, 
                   147.316360473633, 36.5515556335449, 39.1388130187988, 6825.60595703125, 
                   223.89485168457, 40.51416015625, 3852.9033203125, 6198.3271484375, 
                   31.6761646270752, 3922.17944335938, 8932.724609375, 99.9501419067383, 
                   1953.3203125, 17.8548469543457, 6025.58837890625, 2660.92114257812, 
                   4320.4814453125, 7731.85205078125, 21.6971855163574, 2443.56079101562, 
                   1884.89526367188, 3873.46264648438, 9192.90625, 5534.6728515625, 
                   2457.6689453125, 4692.43896484375, 4752.1923828125, 17.2226810455322, 
                   10494.4814453125, 3936.275390625, 36.4867973327637, 995.736145019531, 
                   2464.51782226562, 5272.95263671875, 2894.89672851562, 4621.48828125, 
                   2053.87475585938, 69.7726745605469, 4397.33740234375, 4033.02465820312, 
                   12515.7119140625, 26.2796211242676, 2135.87158203125, 5301.55126953125, 
                   1500.53491210938, 113.466163635254, 1445.24658203125, 2263.4765625, 
                   19.9548740386963, 61.4928359985352, 2497.42431640625, 5724.375, 
                   8840.5888671875, 5299.60546875, 6094.53466796875, 3681.31494140625, 
                   23.5135078430176, 4148.263671875, 4554.11767578125, 7382.83154296875, 
                   9451.5478515625, 11873.4853515625, 19.1808547973633, 3586.09204101562, 
                   4438.634765625, 3001.43383789062, 26.2025279998779, 19.890115737915, 
                   3745.49682617188, 1653.9755859375, 6418.95654296875, 40.1441116333008, 
                   46.305419921875, 3458.98046875, 3113.49682617188, 2829.7958984375, 
                   301.151763916016, 4571.408203125, 557.903869628906, 4430.8515625, 
                   2556.6044921875, 4156.546875, 5109.29248046875, 4910.63818359375, 
                   5720.5234375, 65.8748245239258, 4113.7998046875, 2613.39453125, 
                   838.172546386719, 4482.263671875, 33.2303695678711, 34.3096771240234, 
                   4829.2919921875, 3579.91845703125, 25.8849029541016, 7695.10595703125, 
                   2663.75512695312, 34.5378723144531, 9801.3310546875, 66.9171295166016, 
                   25.0214557647705, 5048, 1960.38513183594, 4761.26171875, 78.6846771240234, 
                   188.922164916992, 37.5876922607422, 4361.2578125, 38.0348320007324, 
                   1235.82067871094, 2208.96850585938, 3337.35473632812, 3252.78930664062, 
                   3256.09497070312, 2295.92358398438, 3716.86743164062, 5517.85107421875, 
                   1838.93212890625, 33.2550392150879, 4405.0712890625, 28.9840602874756, 
                   4956.63525390625, 6683.2607421875, 5968.76123046875, 2645.07690429688, 
                   5123.1630859375, 3765.96655273438, 3527.0693359375, 5350.80810546875, 
                   8745.4248046875, 2230.72119140625, 3204.60278320312, 4790.544921875, 
                   4652.91162109375, 14441.8388671875, 7332.30419921875, 2390.736328125, 
                   4187.908203125, 274.875213623047, 4117.9169921875, 2361.20654296875, 
                   7641.94580078125, 1939.60998535156, 28.1730365753174, 49.8332176208496, 
                   5043.57177734375, 3476.97705078125, 639.604431152344, 1792.62670898438, 
                   5801.16015625, 4456.8720703125, 2826.95581054688, 334.431457519531, 
                   9661.6953125, 4075.61108398438, 5026.71923828125, 4334.1669921875, 
                   28.9316368103027, 8949.435546875, 6976.5146484375, 5205.064453125, 
                   60.3672714233398, 3477.03271484375, 19.1993579864502, 21.9192142486572, 
                   3684.216796875, 4352.740234375, 57.3883781433105, 46.2129096984863, 
                   1596.22338867188, 29.696403503418, 9670.2158203125, 107.693405151367, 
                   3348.19702148438, 5719.65087890625, 55.0786590576172, 3000.45629882812, 
                   6799.7919921875, 17.2596855163574, 4681.7353515625, 12.6371612548828, 
                   16.1341209411621, 3719.31591796875, 11330.365234375, 2451.42749023438, 
                   6951.8017578125, 20.2416610717773, 2804.43530273438, 2000.90234375, 
                   17.1425037384033, 30.6400279998779, 1317.37316894531, 2644.6142578125, 
                   6446.5283203125, 21.9654712677002, 1747.36352539062, 7270.9873046875, 
                   4250.0087890625, 8835.478515625, 112.118576049805, 6103.24609375, 
                   3096.203125, 4711.2529296875, 5478.9462890625, 22.4064464569092, 
                   27.4206047058105, 20.3002529144287, 6511.591796875, 1938.85754394531, 
                   63.1950569152832, 29.4188671112061, 4699.26318359375, 4500.4794921875, 
                   24.6113185882568, 37.6647834777832, 6367.029296875, 37.6647834777832, 
                   8111.38623046875, 11491.1513671875, 467.405364990234, 8745.119140625, 
                   5541.6142578125, 89.3667526245117, 4512.3857421875, 4055.10400390625, 
                   25.1078014373779, 85.5860824584961, 27.8708305358887, 4852.23193359375, 
                   3613.23510742188, 3437.36352539062, 57.564151763916, 38.3062019348145, 
                   8122.19482421875, 1878.92504882812, 33.5264091491699, 6972.00341796875, 
                   11183.2646484375, 115.757385253906, 804.186645507812, 7572.505859375, 
                   1579.259765625, 584.991394042969, 16.2204666137695, 3478.8798828125, 
                   3040.603515625, 19.3967170715332, 4451.7470703125, 3440.92822265625, 
                   1600.72863769531), ncol = 1
)

colnames(matrix) <- "SSC-H"
fr <- flowFrame(exprs = matrix)

test_gate_1 <- gate_mindensity2(fr, channel = "SSC-H")
ggcyto(fr, aes(x = "SSC-H")) +
  geom_density() +
  geom_gate(test_gate_1)


test_gate_2 <- gate_mindensity2(fr, channel = "SSC-H", gate_range = c(0,5000))
ggcyto(fr, aes(x = "SSC-H")) +
  geom_density() +
  geom_gate(test_gate_2)


test_gate_3 <- gate_mindensity2(fr, channel = "SSC-H", min = 0, max = 5000)
ggcyto(fr, aes(x = "SSC-H")) +
  geom_density() +
  geom_gate(test_gate_3)


sessionInfo()
#> R version 4.2.2 (2022-10-31)
#> Platform: x86_64-apple-darwin17.0 (64-bit)
#> Running under: macOS Big Sur ... 10.16
#> 
#> Matrix products: default
#> BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
#> LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] ggcyto_1.26.4        flowWorkspace_4.10.1 ncdfFlow_2.44.0     
#> [4] BH_1.81.0-1          flowCore_2.10.0      ggplot2_3.4.2       
#> [7] openCyto_2.10.1     
#> 
#> loaded via a namespace (and not attached):
#>  [1] tidyselect_1.2.0    xfun_0.38           lattice_0.21-8     
#>  [4] colorspace_2.1-0    vctrs_0.6.1         generics_0.1.3     
#>  [7] htmltools_0.5.5     stats4_4.2.2        yaml_2.3.7         
#> [10] utf8_1.2.3          XML_3.99-0.14       RBGL_1.74.0        
#> [13] rlang_1.1.0         hexbin_1.28.3       pillar_1.9.0       
#> [16] glue_1.6.2          withr_2.5.0         DBI_1.1.3          
#> [19] Rgraphviz_2.42.0    BiocGenerics_0.44.0 RColorBrewer_1.1-3 
#> [22] plyr_1.8.8          matrixStats_0.63.0  lifecycle_1.0.3    
#> [25] zlibbioc_1.44.0     RProtoBufLib_2.10.0 munsell_0.5.0      
#> [28] gtable_0.3.3        cytolib_2.10.1      evaluate_0.20      
#> [31] labeling_0.4.2      Biobase_2.58.0      knitr_1.42         
#> [34] fastmap_1.1.1       flowClust_3.36.1    parallel_4.2.2     
#> [37] fansi_1.0.4         Rcpp_1.0.10         scales_1.2.1       
#> [40] S4Vectors_0.36.2    graph_1.76.0        farver_2.1.1       
#> [43] fs_1.6.1            gridExtra_2.3       digest_0.6.31      
#> [46] dplyr_1.1.1         grid_4.2.2          cli_3.6.1          
#> [49] tools_4.2.2         magrittr_2.0.3      tibble_3.2.1       
#> [52] pkgconfig_2.0.3     data.table_1.14.8   reprex_2.0.2       
#> [55] rmarkdown_2.21      rstudioapi_0.14     R6_2.5.1           
#> [58] compiler_4.2.2

Created on 2023-04-10 with reprex v2.0.2

djhammill commented 2 weeks ago

@maximesunnen the outputs look correct to me, we can try to help if you provide additional context or explanation of the expected result in each case.

maximesunnen commented 6 days ago

@djhammill so for you the minimum is located at the intersection of the red and black line in the last 2 plots? The valley is located more on the left for me.

djhammill commented 4 days ago

Mindensity uses adjust = 2 while geom_smooth uses adjust = 1 for the kernel density estimates. I suspect that if you set geom_density(adjust = 2) the locations will line up better.