Denoise pair returning DataFrame' object has no attribute 'map' error

Hello

I try to run following python code:

from qiime2 import Artifact
from qiime2.plugins import demux, dada2
from qiime2.plugins.dada2.methods import denoise_paired

demuxed = Artifact.import_data(
    'SampleData[PairedEndSequencesWithQuality]',
    './data/3_gardiner_2017/manifest.csv',
    view_type='PairedEndFastqManifestPhred33'
)

result = denoise_paired(
    demultiplexed_seqs=demuxed,
    trunc_len_f=250,
    trunc_len_r=250,
    n_threads=8
)

But after step 7) Write output I have following error:

AttributeError: 'DataFrame' object has no attribute 'map'

It seems all calculation is going fine up to the end. How to fix that?

Hey @Michal_Bukowski,

Welcome to the :qiime2: forum :waving_hand:

From your code block, I'm only seeing two actions (rather than the 7 you mention)- the import_data step and denoise_paired step. Can you share your entire Python session with all commands, including where the AttributeError originates from (full page screenshot or all commands and traceback)?

Thanks! :lizard:

Hello

My mistake, I was mentioning steps of dada2 denoising


And here is the traceback

AttributeError Traceback (most recent call last)
/tmp/ipykernel_62949/18872988.py in ?()
1 from qiime2.plugins.dada2.methods import denoise_paired
2
3 # TODO change manifest to be cross users
----> 4 result = denoise_paired(
5 demultiplexed_seqs=demuxed,
6 trunc_len_f=250,
7 trunc_len_r=250,

in ?(demultiplexed_seqs, trunc_len_f, trunc_len_r, trim_left_f, trim_left_r, max_ee_f, max_ee_r, trunc_q, min_overlap, pooling_method, chimera_method, min_fold_parent_over_abundance, allow_one_off, n_threads, n_reads_learn, hashed_feature_ids, retain_all_samples)
1 'Could not get source, probably due dynamically evaluated source code.'

~/miniconda3/envs/micro_env/lib/python3.10/site-packages/qiime2/sdk/action.py in ?(*args, **kwargs)
295 callable_args =
296 self.signature.transform_and_add_callable_args_to_prov(
297 provenance, **callable_args)
298
--> 299 outputs = self.callable_executor(
300 ctx, callable_args, output_types, provenance)
301
302 if len(outputs) != len(self.signature.outputs):

~/miniconda3/envs/micro_env/lib/python3.10/site-packages/qiime2/sdk/action.py in ?(self, ctx, view_args, output_types, provenance)
583 "semantic types: %d != %d"
584 % (len(output_views), len(output_types)))
585
586 output_artifacts =
--> 587 self.signature.coerce_given_outputs(output_views, output_types,
588 ctx, provenance)
589
590 return tuple(output_artifacts)

~/miniconda3/envs/micro_env/lib/python3.10/site-packages/qiime2/core/type/signature.py in ?(self, output_views, output_types, ctx, provenance)
494 raise TypeError(
495 "Expected output view type %r, received %r" %
496 (spec.view_type.name, type(output_view).name))
497 else:
--> 498 output = self._create_output_artifact(
499 provenance, name, ctx, spec, output_view)
500
501 outputs.append(output)

~/miniconda3/envs/micro_env/lib/python3.10/site-packages/qiime2/core/type/signature.py in ?(self, provenance, name, ctx, spec, view)
516 # ResultCollection outside of this method.
517 if is_collection_type(qiime_type):
518 qiime_type = qiime_type.fields[0]
519
--> 520 artifact = qiime2.sdk.Artifact._from_view(
521 qiime_type, view, spec.view_type, prov)
522 artifact = ctx.add_parent_reference(artifact)
523

~/miniconda3/envs/micro_env/lib/python3.10/site-packages/qiime2/sdk/result.py in ?(cls, type, view, view_type, provenance_capture, validate_level)
370
371 recorder = provenance_capture.transformation_recorder('return')
372 transformation = from_type.make_transformation(to_type,
373 recorder=recorder)
--> 374 result = transformation(view, validate_level)
375
376 if type_raw in pm.validators:
377 validation_object = pm.validators[type]

~/miniconda3/envs/micro_env/lib/python3.10/site-packages/qiime2/core/transform.py in ?(view, validate_level)
66 def transformation(view, validate_level='min'):
67 view = self.coerce_view(view)
68 self.validate(view, level=validate_level)
69
---> 70 new_view = transformer(view)
71
72 new_view = other.coerce_view(new_view)
73 other.validate(new_view)

~/miniconda3/envs/micro_env/lib/python3.10/site-packages/qiime2/core/transform.py in ?(view)
219 def wrapped(view):
220 new_view = self._view_type()
--> 221 file_view = transformer(view)
222 if transformer is not identity_transformer:
223 self.set_user_owned(file_view, False)
224 new_view.file.write_data(file_view, self._wrapped_view_type)

~/miniconda3/envs/micro_env/lib/python3.10/site-packages/q2_dada2/_transformer.py in ?(obj)
20 @plugin.register_transformer
21 def _2(obj: qiime2.Metadata) -> DADA2StatsFormat:
22 ff = DADA2StatsFormat()
---> 23 obj.save(str(ff))
24 return ff

~/miniconda3/envs/micro_env/lib/python3.10/site-packages/qiime2/metadata/metadata.py in ?(self, filepath, ext)
251
252 if not filepath.endswith(ext):
253 filepath += ext
254
--> 255 MetadataWriter(self).write(filepath)
256 return filepath

~/miniconda3/envs/micro_env/lib/python3.10/site-packages/qiime2/metadata/io.py in ?(self, filepath)
414 tsv_writer.writerow(missing_directive)
415
416 df = md.to_dataframe(encode_missing=True)
417 df.fillna('', inplace=True)
--> 418 df = df.map(self._format)
419 tsv_writer.writerows(df.itertuples(index=True))

~/.local/lib/python3.10/site-packages/pandas/core/generic.py in ?(self, name)
5985 and name not in self._accessors
5986 and self._info_axis._can_hold_identifiers_and_holds_name(name)
5987 ):
5988 return self[name]
-> 5989 return object.getattribute(self, name)

AttributeError: 'DataFrame' object has no attribute 'map'

Hey @Michal_Bukowski,

Apologies for the delayed reply! I'd like to try and reproduce this on my end; could you provide me with the following?

  • The OS you're running this on (OSX, Linux, etc)
  • What version of QIIME 2 you have installed
  • The output artifact of the last successful command you ran before receiving this error (i.e. the demuxed object, saved to disk). Feel free to DM this to me if you'd prefer not to share publicly

Thanks! :lizard: