DaliangNing / iCAMP1

Infer Community Assembly Mechanisms by Phylogenetic bin-based null model analysis (Version 1)
GNU General Public License v2.0
68 stars 25 forks source link

icamp.bins - arguments imply differing number of rows #52

Closed mgabriell1 closed 7 months ago

mgabriell1 commented 8 months ago

Hi, Thanks for developing and maintaining this tool! I'm analyzing some of my own data using iCamp v1.6.5, but I'm having an issue with the command icamp.bins in step 10 which gives me the output below:

Now summarizing method=CbMPDiCbraya i=1 j=1. Mon Feb 26 13:52:57 2024
bootstrapping rt=1. Mon Feb 26 13:52:57 2024
bootstrapping rt=201. Mon Feb 26 13:52:58 2024
bootstrapping rt=401. Mon Feb 26 13:52:58 2024
bootstrapping rt=601. Mon Feb 26 13:52:59 2024
bootstrapping rt=801. Mon Feb 26 13:52:59 2024
Error in data.frame(Method = mij.name, GroupBasedOn = colnames(treat)[i],  : 
  arguments imply differing number of rows: 1, 15, 8

I've looked at the source code and the issue refers to lines 210-212. This is the content of the different columns of the data.frame:

> mij.name
[1] "CbMPDiCbraya"
> colnames(treat)[i]
[1] "Condition"
> trti.lev[j]
[[1]]
 [1] "30" "30" "30" "30" "50" "50" "50" "50" "40" "40" "40" "40" "20" "20" "20"

> c(procn, rownames(dpij))
[1] "HeS"                       "HoS"                       "DL"                        "HD"                        "DR"                        "DominantProcess"           "DominantProcessImportance"
> rbind(ptkij, dpij)
                          bin1                  bin2                  bin3                  bin4                   bin5                  bin6                   bin7                  bin8                   bin9                
HeS                       "0"                   "0"                   "0"                   "0"                    "0"                   "9.7879282218597e-05"  "0.0546463695172222"  "0.129598336149747"    "0.0139240797899295"
HoS                       "0.463154456518275"   "0.137119759930767"   "0.122451651516852"   "0.000253108264103098" "0"                   "1.39827546026567e-05" "0"                   "0.228519433251007"    "0.0163464934506534"
DL                        "0.272019693445078"   "0.236570684262292"   "0.704428982905024"   "0.757595613420888"    "0.688138584432473"   "0.8821067350268"      "0.855097188556607"   "0.571688548030677"    "0.414386296279234" 
HD                        "0.00117109078741914" "0.00728359654900478" "0.00701380316462799" "0.00145714664193933"  "0.00163580820277829" "0.000144488464227453" "0.00907041731639159" "0.000519953204211621" "0.0184195574392285"
DR                        "0.263654759249227"   "0.619025959257936"   "0.166105562413496"   "0.240694131673069"    "0.310225607364749"   "0.117636914472151"    "0.0811860246097791"  "0.0696737293643572"   "0.536923573040955" 
DominantProcess           "HoS"                 "DR"                  "DL"                  "DL"                   "DL"                  "DL"                   "DL"                  "DL"                   "DR"                
DominantProcessImportance "0.463154456518275"   "0.619025959257936"   "0.704428982905024"   "0.757595613420888"    "0.688138584432473"   "0.8821067350268"      "0.855097188556607"   "0.571688548030677"    "0.536923573040955" 
                          bin10                  bin11                 bin12                  bin13                 bin14                  bin15                 bin16                bin17                bin18              
HeS                       "0.271479847453825"    "0.190101237345332"   "0.000802349668848409" "0"                   "0"                    "0"                   "0"                  "0"                  "0"                
HoS                       "0.000181602589439275" "0"                   "0"                    "0.0224317926029417"  "0"                    "0"                   "0"                  "0.0638190876416058" "0"                
DL                        "0.676998429671727"    "0.530049815201671"   "0.700752749871138"    "0.852883533201382"   "0.317865061767501"    "0.454717303421967"   "0.380443211826601"  "0.554955650327587"  "0.666005358342812"
HD                        "0.00180000213650105"  "0.00216937168568215" "0.0136253561946257"   "0.00395855163581325" "0.000248497637710966" "0.00269632497611772" "0.0125710693980172" "0.0236087613018247" "0"                
DR                        "0.0495401181485082"   "0.277679575767315"   "0.284819544265388"    "0.120726122559863"   "0.681886440594788"    "0.542586371601915"   "0.606985718775383"  "0.357616500728982"  "0.333994641657188"
DominantProcess           "DL"                   "DL"                  "DL"                   "DL"                  "DR"                   "DR"                  "DR"                 "DL"                 "DL"               
DominantProcessImportance "0.676998429671727"    "0.530049815201671"   "0.700752749871138"    "0.852883533201382"   "0.681886440594788"    "0.542586371601915"   "0.606985718775383"  "0.554955650327587"  "0.666005358342812"
                          bin19                
HeS                       "0.123503591380686"  
HoS                       "0.0665403032721468" 
DL                        "0.668994413407821"  
HD                        "0.00179569034317638"
DR                        "0.139166001596169"  
DominantProcess           "DL"                 
DominantProcessImportance "0.668994413407821" 

Where mij.name has length 1, trti.lev[j] 15 and both c(procn, rownames(dpij)) and rbind(ptkij, dpij) 7.

How can I solve this issue? Thanks for the help!

mgabriell1 commented 8 months ago

Comparing with the example data I have found the issue: treat was derived directly from a phyloseq object leaving the sample_data class in the resulting data.frame. Removing it as below seemed to have solved the issue.

treat_ps <- treat
treat<-unclass(treat_ps)
treat<-as.data.frame(treat, row.names = row.names(treat_ps))

I guess this might still be useful to someone. Cheers

cckeneally commented 8 months ago

Had a similar issue with phyloseq <-> iCAMP and this fix worked! Thanks